Mercurial > libavcodec.hg
comparison bink.c @ 11251:56e65f21e9c5 libavcodec
Bink video decoder now can use extradata to detect alpha plane presence
author | kostya |
---|---|
date | Tue, 23 Feb 2010 06:39:23 +0000 |
parents | b48dd9213016 |
children | d6513f6a949e |
comparison
equal
deleted
inserted
replaced
11250:4a6bf3fbf367 | 11251:56e65f21e9c5 |
---|---|
24 #include "binkdata.h" | 24 #include "binkdata.h" |
25 #include "mathops.h" | 25 #include "mathops.h" |
26 | 26 |
27 #define ALT_BITSTREAM_READER_LE | 27 #define ALT_BITSTREAM_READER_LE |
28 #include "get_bits.h" | 28 #include "get_bits.h" |
29 | |
30 #define BINK_FLAG_ALPHA 0x00100000 | |
31 #define BINK_FLAG_GRAY 0x00020000 | |
29 | 32 |
30 static VLC bink_trees[16]; | 33 static VLC bink_trees[16]; |
31 | 34 |
32 /** | 35 /** |
33 * IDs for different data types used in Bink video codec | 36 * IDs for different data types used in Bink video codec |
928 static av_cold int decode_init(AVCodecContext *avctx) | 931 static av_cold int decode_init(AVCodecContext *avctx) |
929 { | 932 { |
930 BinkContext * const c = avctx->priv_data; | 933 BinkContext * const c = avctx->priv_data; |
931 static VLC_TYPE table[16 * 128][2]; | 934 static VLC_TYPE table[16 * 128][2]; |
932 int i; | 935 int i; |
936 int flags; | |
933 | 937 |
934 c->version = avctx->codec_tag >> 24; | 938 c->version = avctx->codec_tag >> 24; |
935 if (c->version < 'c') { | 939 if (c->version < 'c') { |
936 av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version); | 940 av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version); |
937 return -1; | 941 return -1; |
938 } | 942 } |
939 c->has_alpha = 0; //TODO: demuxer should supply decoder with flags | 943 if (avctx->extradata_size < 4) { |
944 av_log(avctx, AV_LOG_ERROR, "Extradata missing or too short\n"); | |
945 return -1; | |
946 } | |
947 flags = AV_RL32(avctx->extradata); | |
948 c->has_alpha = flags & BINK_FLAG_ALPHA; | |
940 c->swap_planes = c->version >= 'i'; | 949 c->swap_planes = c->version >= 'i'; |
941 if (!bink_trees[15].table) { | 950 if (!bink_trees[15].table) { |
942 for (i = 0; i < 16; i++) { | 951 for (i = 0; i < 16; i++) { |
943 const int maxbits = bink_tree_lens[i][15]; | 952 const int maxbits = bink_tree_lens[i][15]; |
944 bink_trees[i].table = table + i*128; | 953 bink_trees[i].table = table + i*128; |