Mercurial > libavcodec.hg
comparison bink.c @ 11247:b48dd9213016 libavcodec
Make Bink decoder able to skip alpha plane
author | kostya |
---|---|
date | Mon, 22 Feb 2010 14:59:51 +0000 |
parents | 1e9ff636c3db |
children | 56e65f21e9c5 |
comparison
equal
deleted
inserted
replaced
11246:b75449aaea3e | 11247:b48dd9213016 |
---|---|
75 typedef struct BinkContext { | 75 typedef struct BinkContext { |
76 AVCodecContext *avctx; | 76 AVCodecContext *avctx; |
77 DSPContext dsp; | 77 DSPContext dsp; |
78 AVFrame pic, last; | 78 AVFrame pic, last; |
79 int version; ///< internal Bink file version | 79 int version; ///< internal Bink file version |
80 int has_alpha; | |
80 int swap_planes; | 81 int swap_planes; |
81 ScanTable scantable; ///< permutated scantable for DCT coeffs decoding | 82 ScanTable scantable; ///< permutated scantable for DCT coeffs decoding |
82 | 83 |
83 Bundle bundle[BINK_NB_SRC]; ///< bundles for decoding all data types | 84 Bundle bundle[BINK_NB_SRC]; ///< bundles for decoding all data types |
84 Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type | 85 Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type |
690 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | 691 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
691 return -1; | 692 return -1; |
692 } | 693 } |
693 | 694 |
694 init_get_bits(&gb, pkt->data, bits_count); | 695 init_get_bits(&gb, pkt->data, bits_count); |
696 if (c->has_alpha) { | |
697 int aplane_bits = get_bits_long(&gb, 32) << 3; | |
698 if (aplane_bits <= 32 || (aplane_bits & 0x1F)) { | |
699 av_log(avctx, AV_LOG_ERROR, "Incorrect alpha plane size %d\n", aplane_bits); | |
700 return -1; | |
701 } | |
702 skip_bits_long(&gb, aplane_bits - 32); | |
703 } | |
695 if (c->version >= 'i') | 704 if (c->version >= 'i') |
696 skip_bits_long(&gb, 32); | 705 skip_bits_long(&gb, 32); |
697 | 706 |
698 for (plane = 0; plane < 3; plane++) { | 707 for (plane = 0; plane < 3; plane++) { |
699 const int stride = c->pic.linesize[plane]; | 708 const int stride = c->pic.linesize[plane]; |
925 c->version = avctx->codec_tag >> 24; | 934 c->version = avctx->codec_tag >> 24; |
926 if (c->version < 'c') { | 935 if (c->version < 'c') { |
927 av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version); | 936 av_log(avctx, AV_LOG_ERROR, "Too old version '%c'\n", c->version); |
928 return -1; | 937 return -1; |
929 } | 938 } |
939 c->has_alpha = 0; //TODO: demuxer should supply decoder with flags | |
930 c->swap_planes = c->version >= 'i'; | 940 c->swap_planes = c->version >= 'i'; |
931 if (!bink_trees[15].table) { | 941 if (!bink_trees[15].table) { |
932 for (i = 0; i < 16; i++) { | 942 for (i = 0; i < 16; i++) { |
933 const int maxbits = bink_tree_lens[i][15]; | 943 const int maxbits = bink_tree_lens[i][15]; |
934 bink_trees[i].table = table + i*128; | 944 bink_trees[i].table = table + i*128; |