~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavcodec/huffyuv.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "avcodec.h"
32
32
#include "bitstream.h"
33
33
#include "dsputil.h"
 
34
#include "mathops.h"
34
35
 
35
36
#define VLC_BITS 11
36
37
 
261
262
    return 0;
262
263
}
263
264
 
264
 
#if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER)
 
265
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
265
266
typedef struct {
266
267
    uint64_t val;
267
268
    int name;
268
 
} heap_elem_t;
 
269
} HeapElem;
269
270
 
270
 
static void heap_sift(heap_elem_t *h, int root, int size)
 
271
static void heap_sift(HeapElem *h, int root, int size)
271
272
{
272
273
    while(root*2+1 < size) {
273
274
        int child = root*2+1;
274
275
        if(child < size-1 && h[child].val > h[child+1].val)
275
276
            child++;
276
277
        if(h[root].val > h[child].val) {
277
 
            FFSWAP(heap_elem_t, h[root], h[child]);
 
278
            FFSWAP(HeapElem, h[root], h[child]);
278
279
            root = child;
279
280
        } else
280
281
            break;
282
283
}
283
284
 
284
285
static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){
285
 
    heap_elem_t h[size];
 
286
    HeapElem h[size];
286
287
    int up[2*size];
287
288
    int len[2*size];
288
289
    int offset, i, next;
317
318
        if(i==size) break;
318
319
    }
319
320
}
320
 
#endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */
 
321
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
321
322
 
322
323
static void generate_joint_tables(HYuvContext *s){
323
324
    uint16_t symbols[1<<VLC_BITS];
477
478
    return 0;
478
479
}
479
480
 
480
 
#if defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER)
 
481
#if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
481
482
static av_cold int decode_init(AVCodecContext *avctx)
482
483
{
483
484
    HYuvContext *s = avctx->priv_data;
573
574
 
574
575
    return 0;
575
576
}
576
 
#endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */
 
577
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
577
578
 
578
 
#if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER)
 
579
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
579
580
static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){
580
581
    int i;
581
582
    int index= 0;
725
726
 
726
727
    return 0;
727
728
}
728
 
#endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */
 
729
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
729
730
 
730
731
/* TODO instead of restarting the read when the code isn't in the first level
731
732
 * of the joint table, jump into the 2nd level of the individual table. */
761
762
    }
762
763
}
763
764
 
764
 
#if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER)
 
765
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
765
766
static int encode_422_bitstream(HYuvContext *s, int count){
766
767
    int i;
767
768
 
854
855
    }
855
856
    return 0;
856
857
}
857
 
#endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */
 
858
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
858
859
 
859
860
static av_always_inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){
860
861
    int i;
931
932
    return 0;
932
933
}
933
934
 
934
 
#if defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER)
 
935
#if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
935
936
static void draw_slice(HYuvContext *s, int y){
936
937
    int h, cy;
937
938
    int offset[4];
1198
1199
 
1199
1200
    return (get_bits_count(&s->gb)+31)/32*4 + table_size;
1200
1201
}
1201
 
#endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */
 
1202
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
1202
1203
 
1203
1204
static int common_end(HYuvContext *s){
1204
1205
    int i;
1209
1210
    return 0;
1210
1211
}
1211
1212
 
1212
 
#if defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER)
 
1213
#if CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER
1213
1214
static av_cold int decode_end(AVCodecContext *avctx)
1214
1215
{
1215
1216
    HYuvContext *s = avctx->priv_data;
1224
1225
 
1225
1226
    return 0;
1226
1227
}
1227
 
#endif /* defined(CONFIG_HUFFYUV_DECODER) || defined(CONFIG_FFVHUFF_DECODER) */
 
1228
#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
1228
1229
 
1229
 
#if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER)
 
1230
#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
1230
1231
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){
1231
1232
    HYuvContext *s = avctx->priv_data;
1232
1233
    AVFrame *pict = data;
1431
1432
 
1432
1433
    return 0;
1433
1434
}
1434
 
#endif /* defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER) */
 
1435
#endif /* CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER */
1435
1436
 
1436
 
#ifdef CONFIG_HUFFYUV_DECODER
 
1437
#if CONFIG_HUFFYUV_DECODER
1437
1438
AVCodec huffyuv_decoder = {
1438
1439
    "huffyuv",
1439
1440
    CODEC_TYPE_VIDEO,
1449
1450
};
1450
1451
#endif
1451
1452
 
1452
 
#ifdef CONFIG_FFVHUFF_DECODER
 
1453
#if CONFIG_FFVHUFF_DECODER
1453
1454
AVCodec ffvhuff_decoder = {
1454
1455
    "ffvhuff",
1455
1456
    CODEC_TYPE_VIDEO,
1465
1466
};
1466
1467
#endif
1467
1468
 
1468
 
#ifdef CONFIG_HUFFYUV_ENCODER
 
1469
#if CONFIG_HUFFYUV_ENCODER
1469
1470
AVCodec huffyuv_encoder = {
1470
1471
    "huffyuv",
1471
1472
    CODEC_TYPE_VIDEO,
1479
1480
};
1480
1481
#endif
1481
1482
 
1482
 
#ifdef CONFIG_FFVHUFF_ENCODER
 
1483
#if CONFIG_FFVHUFF_ENCODER
1483
1484
AVCodec ffvhuff_encoder = {
1484
1485
    "ffvhuff",
1485
1486
    CODEC_TYPE_VIDEO,