Mercurial > libavcodec.hg
annotate vc9.c @ 2504:f12657081093 libavcodec
INTRA PCM macroblocks support patch by (Loic )lll+ffmpeg m4x org)
This patch adds the support for INTRA PCM macroblocks in CAVLC and CABAC
mode, the deblocking needed a small modification and so did the
intra4x4_pred_mode prediction.
With this patch, the 5 streams of the conformance suite containing INTRA
PCM macroblocks now decode entirely, 4 are completely corrects, 1 is
incorrect since the first B slice because of deblocking in B slice not
yet implemented.
The code is not optimized for speed, it is not necessary IPCM
macroblocks are rare, but it could be optimized for code size, if
someone want to do this, feel free.
author | michael |
---|---|
date | Mon, 07 Feb 2005 00:10:28 +0000 |
parents | 69adfbbdcdeb |
children | 2c794e3903a2 |
rev | line source |
---|---|
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1 /* |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2 * VC-9 and WMV3 decoder |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
3 * Copyright (c) 2005 Anonymous |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
4 * Copyright (c) 2005 Alex Beregszaszi |
2462 | 5 * Copyright (c) 2005 Michael Niedermayer |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
6 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
7 * This library is free software; you can redistribute it and/or |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
10 * version 2 of the License, or (at your option) any later version. |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
11 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
12 * This library is distributed in the hope that it will be useful, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
16 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
18 * License along with this library; if not, write to the Free Software |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
20 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
21 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
22 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
23 /** |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
24 * @file vc9.c |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
25 * VC-9 and WMV3 decoder |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
26 * |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
27 * TODO: most AP stuff, optimize, most of MB layer, transform, filtering and motion compensation, etc |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
28 * TODO: use MPV_ !! |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
29 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
30 #include "common.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
31 #include "dsputil.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
32 #include "avcodec.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
33 #include "mpegvideo.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
34 #include "vc9data.h" |
2474 | 35 |
2476
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
36 #undef NDEBUG |
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
37 #include <assert.h> |
38dbec9a148d
100000l (typos in the #define for selecting the NORM6 method -> wasnt compiled, after fixing typos new method doesnt even compile -> swicth back to old until its fixed)
michael
parents:
2475
diff
changeset
|
38 |
2465
5565203c95ee
use dc tables from msmpeg4 instead of duplicating them patch by anonymous
michael
parents:
2464
diff
changeset
|
39 extern const uint32_t ff_table0_dc_lum[120][2], ff_table1_dc_lum[120][2]; |
5565203c95ee
use dc tables from msmpeg4 instead of duplicating them patch by anonymous
michael
parents:
2464
diff
changeset
|
40 extern const uint32_t ff_table0_dc_chroma[120][2], ff_table1_dc_chroma[120][2]; |
2474 | 41 extern VLC ff_msmp4_dc_luma_vlc[2], ff_msmp4_dc_chroma_vlc[2]; |
42 #define MB_INTRA_VLC_BITS 9 | |
43 extern VLC ff_msmp4_mb_i_vlc; | |
44 #define DC_VLC_BITS 9 | |
45 static const uint16_t table_mb_intra[64][2]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
46 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
47 /* Some inhibiting stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
48 #define HAS_ADVANCED_PROFILE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
49 #define TRACE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
50 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
51 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
52 # define INIT_VLC(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
53 codes, codes_wrap, codes_size, use_static) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
54 if (init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
55 codes, codes_wrap, codes_size, use_static) < 0) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
56 { \ |
2474 | 57 av_log(v->s.avctx, AV_LOG_ERROR, "Error for " # vlc " (%i)\n", i); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
58 return -1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
59 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
60 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
61 # define INIT_VLC(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
62 codes, codes_wrap, codes_size, use_static) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
63 init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
64 codes, codes_wrap, codes_size, use_static) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
65 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
66 |
2482 | 67 /** Available Profiles */ |
68 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
69 #define PROFILE_SIMPLE 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
70 #define PROFILE_MAIN 1 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
71 #define PROFILE_COMPLEX 2 ///< TODO: WMV9 specific |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
72 #define PROFILE_ADVANCED 3 |
2482 | 73 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
74 |
2482 | 75 /** Sequence quantizer mode */ |
76 //@{ | |
2483 | 77 #define QUANT_FRAME_IMPLICIT 0 ///< Implicitly specified at frame level |
78 #define QUANT_FRAME_EXPLICIT 1 ///< Explicitly specified at frame level | |
79 #define QUANT_NON_UNIFORM 2 ///< Non-uniform quant used for all frames | |
80 #define QUANT_UNIFORM 3 ///< Uniform quant used for all frames | |
2482 | 81 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
82 |
2482 | 83 /** Where quant can be changed */ |
84 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
85 #define DQPROFILE_FOUR_EDGES 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
86 #define DQPROFILE_DOUBLE_EDGES 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
87 #define DQPROFILE_SINGLE_EDGE 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
88 #define DQPROFILE_ALL_MBS 3 |
2482 | 89 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
90 |
2482 | 91 /** @name Where quant can be changed |
92 */ | |
93 //@{ | |
94 #define DQPROFILE_FOUR_EDGES 0 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
95 #define DQSINGLE_BEDGE_LEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
96 #define DQSINGLE_BEDGE_TOP 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
97 #define DQSINGLE_BEDGE_RIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
98 #define DQSINGLE_BEDGE_BOTTOM 3 |
2482 | 99 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
100 |
2482 | 101 /** Which pair of edges is quantized with ALTPQUANT */ |
102 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
103 #define DQDOUBLE_BEDGE_TOPLEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
104 #define DQDOUBLE_BEDGE_TOPRIGHT 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
105 #define DQDOUBLE_BEDGE_BOTTOMRIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
106 #define DQDOUBLE_BEDGE_BOTTOMLEFT 3 |
2482 | 107 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
108 |
2482 | 109 /** MV modes for P frames */ |
110 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
111 #define MV_PMODE_1MV_HPEL_BILIN 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
112 #define MV_PMODE_1MV 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
113 #define MV_PMODE_1MV_HPEL 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
114 #define MV_PMODE_MIXED_MV 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
115 #define MV_PMODE_INTENSITY_COMP 4 |
2482 | 116 //@} |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
117 |
2482 | 118 /** @name MV types for B frames */ |
119 //@{ | |
120 #define BMV_TYPE_BACKWARD 0 | |
2462 | 121 #define BMV_TYPE_BACKWARD 0 |
122 #define BMV_TYPE_FORWARD 1 | |
123 #define BMV_TYPE_INTERPOLATED 3 | |
2482 | 124 //@} |
2462 | 125 |
2482 | 126 /** MV P mode - the 5th element is only used for mode 1 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
127 static const uint8_t mv_pmode_table[2][5] = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
128 { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV, MV_PMODE_INTENSITY_COMP }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
129 { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_INTENSITY_COMP } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
130 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
131 |
2482 | 132 /** One more frame type */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
133 #define BI_TYPE 7 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
134 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
135 static const int fps_nr[5] = { 24, 25, 30, 50, 60 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
136 fps_dr[2] = { 1000, 1001 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
137 static const uint8_t pquant_table[3][32] = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
138 { /* Implicit quantizer */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
139 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
140 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
141 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
142 { /* Explicit quantizer, pquantizer uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
143 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
144 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
145 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
146 { /* Explicit quantizer, pquantizer non-uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
147 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
148 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
149 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
150 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
151 |
2482 | 152 /** @name VC-9 VLC tables and defines |
153 * @todo TODO move this into the context | |
154 */ | |
155 //@{ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
156 #define VC9_BFRACTION_VLC_BITS 7 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
157 static VLC vc9_bfraction_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
158 #define VC9_IMODE_VLC_BITS 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
159 static VLC vc9_imode_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
160 #define VC9_NORM2_VLC_BITS 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
161 static VLC vc9_norm2_vlc; |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
162 #define VC9_NORM6_VLC_BITS 9 |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
163 static VLC vc9_norm6_vlc; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
164 /* Could be optimized, one table only needs 8 bits */ |
2462 | 165 #define VC9_TTMB_VLC_BITS 9 //12 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
166 static VLC vc9_ttmb_vlc[3]; |
2462 | 167 #define VC9_MV_DIFF_VLC_BITS 9 //15 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
168 static VLC vc9_mv_diff_vlc[4]; |
2462 | 169 #define VC9_CBPCY_P_VLC_BITS 9 //14 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
170 static VLC vc9_cbpcy_p_vlc[4]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
171 #define VC9_4MV_BLOCK_PATTERN_VLC_BITS 6 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
172 static VLC vc9_4mv_block_pattern_vlc[4]; |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
173 #define VC9_TTBLK_VLC_BITS 5 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
174 static VLC vc9_ttblk_vlc[3]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
175 #define VC9_SUBBLKPAT_VLC_BITS 6 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
176 static VLC vc9_subblkpat_vlc[3]; |
2482 | 177 //@} |
2462 | 178 |
2482 | 179 /** Bitplane struct |
180 * We mainly need data and is_raw, so this struct could be avoided | |
181 * to save a level of indirection; feel free to modify | |
182 * @fixme For now, stride=width | |
183 * @warning Data are bits, either 1 or 0 | |
184 */ | |
2462 | 185 typedef struct BitPlane { |
2482 | 186 uint8_t *data; ///< Data buffer |
187 int width; ///< Width of the buffer | |
188 int stride; ///< Stride of the buffer | |
189 int height; ///< Plane height | |
190 uint8_t is_raw; ///< Bit values must be read at MB level | |
2462 | 191 } BitPlane; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
192 |
2482 | 193 /** The VC9 Context */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
194 typedef struct VC9Context{ |
2482 | 195 MpegEncContext s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
196 |
2482 | 197 /** Simple/Main Profile sequence header */ |
198 //@{ | |
199 int res_sm; ///< reserved, 2b | |
200 int res_x8; ///< reserved | |
201 int multires; ///< frame-level RESPIC syntax element present | |
202 int res_fasttx; ///< reserved, always 1 | |
203 int res_transtab; ///< reserved, always 0 | |
204 int rangered; ///< RANGEREDFRM (range reduction) syntax element present | |
205 ///< at frame level | |
206 int res_rtm_flag; ///< reserved, set to 1 | |
207 int reserved; ///< reserved | |
208 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
209 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
210 #if HAS_ADVANCED_PROFILE |
2482 | 211 /** Advanced Profile */ |
212 //@{ | |
213 int level; ///< 3bits, for Advanced/Simple Profile, provided by TS layer | |
214 int chromaformat; ///< 2bits, 2=4:2:0, only defined | |
215 int postprocflag; ///< Per-frame processing suggestion flag present | |
216 int broadcast; ///< TFF/RFF present | |
217 int interlace; ///< Progressive/interlaced (RPTFTM syntax element) | |
218 int tfcntrflag; ///< TFCNTR present | |
219 int panscanflag; ///< NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present | |
220 int extended_dmv; ///< Additional extended dmv range at P/B frame-level | |
221 int color_prim; ///< 8bits, chroma coordinates of the color primaries | |
222 int transfer_char; ///< 8bits, Opto-electronic transfer characteristics | |
223 int matrix_coef; ///< 8bits, Color primaries->YCbCr transform matrix | |
224 int hrd_param_flag; ///< Presence of Hypothetical Reference | |
225 ///< Decoder parameters | |
226 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
227 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
228 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
229 |
2482 | 230 /** Sequence header data for all Profiles |
231 * TODO: choose between ints, uint8_ts and monobit flags | |
232 */ | |
233 //@{ | |
234 int profile; ///< 2bits, Profile | |
235 int frmrtq_postproc; ///< 3bits, | |
236 int bitrtq_postproc; ///< 5bits, quantized framerate-based postprocessing strength | |
237 int fastuvmc; ///< Rounding of qpel vector to hpel ? (not in Simple) | |
238 int extended_mv; ///< Ext MV in P/B (not in Simple) | |
239 int dquant; ///< How qscale varies with MBs, 2bits (not in Simple) | |
240 int vstransform; ///< variable-size [48]x[48] transform type + info | |
241 int overlap; ///< overlapped transforms in use | |
242 int quantizer_mode; ///< 2bits, quantizer mode used for sequence, see QUANT_* | |
243 int finterpflag; ///< INTERPFRM present | |
244 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
245 |
2482 | 246 /** Frame decoding info for all profiles */ |
247 //@{ | |
248 uint8_t mv_mode; ///< MV coding monde | |
249 uint8_t mv_mode2; ///< Secondary MV coding mode (B frames) | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
250 int k_x; ///< Number of bits for MVs (depends on MV range) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
251 int k_y; ///< Number of bits for MVs (depends on MV range) |
2482 | 252 uint8_t pq, altpq; ///< Current/alternate frame quantizer scale |
253 /** pquant parameters */ | |
254 //@{ | |
255 uint8_t dquantfrm; | |
256 uint8_t dqprofile; | |
257 uint8_t dqsbedge; | |
258 uint8_t dqbilevel; | |
259 //@} | |
260 int ac_table_level; ///< Index for AC tables from ACFRM element | |
261 int ttfrm; ///< Transform type info present at frame level | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
262 uint8_t ttmbf; ///< Transform type flag |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
263 int ttmb; ///< Transform type |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
264 uint8_t ttblk4x4; ///< Value of ttblk which indicates a 4x4 transform |
2482 | 265 /** Luma compensation parameters */ |
266 //@{ | |
267 uint8_t lumscale; | |
268 uint8_t lumshift; | |
269 //@} | |
270 int16_t bfraction; ///< Relative position % anchors=> how to scale MVs | |
271 uint8_t halfpq; ///< Uniform quant over image and qp+.5 | |
272 uint8_t respic; ///< Frame-level flag for resized images | |
273 int buffer_fullness; ///< HRD info | |
274 /** Ranges: | |
275 * -# 0 -> [-64n 63.f] x [-32, 31.f] | |
276 * -# 1 -> [-128, 127.f] x [-64, 63.f] | |
277 * -# 2 -> [-512, 511.f] x [-128, 127.f] | |
278 * -# 3 -> [-1024, 1023.f] x [-256, 255.f] | |
279 */ | |
280 uint8_t mvrange; | |
2483 | 281 uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use |
2482 | 282 uint8_t *previous_line_cbpcy; ///< To use for predicted CBPCY |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
283 VLC *cbpcy_vlc; ///< CBPCY VLC table |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
284 int tt_index; ///< Index for Transform Type tables |
2482 | 285 BitPlane mv_type_mb_plane; ///< bitplane for mv_type == (4MV) |
286 BitPlane skip_mb_plane; ///< bitplane for skipped MBs | |
287 BitPlane direct_mb_plane; ///< bitplane for "direct" MBs | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
288 |
2482 | 289 /** Frame decoding info for S/M profiles only */ |
290 //@{ | |
291 uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128) | |
292 uint8_t interpfrm; | |
293 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
294 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
295 #if HAS_ADVANCED_PROFILE |
2482 | 296 /** Frame decoding info for Advanced profile */ |
297 //@{ | |
298 uint8_t fcm; ///< 0->Progressive, 2->Frame-Interlace, 3->Field-Interlace | |
299 uint8_t numpanscanwin; | |
300 uint8_t tfcntr; | |
301 uint8_t rptfrm, tff, rff; | |
2483 | 302 uint16_t topleftx; |
303 uint16_t toplefty; | |
304 uint16_t bottomrightx; | |
305 uint16_t bottomrighty; | |
2482 | 306 uint8_t uvsamp; |
307 uint8_t postproc; | |
308 int hrd_num_leaky_buckets; | |
309 uint8_t bit_rate_exponent; | |
310 uint8_t buffer_size_exponent; | |
311 BitPlane ac_pred_plane; ///< AC prediction flags bitplane | |
312 BitPlane over_flags_plane; ///< Overflags bitplane | |
313 uint8_t condover; | |
314 uint16_t *hrd_rate, *hrd_buffer; | |
315 int ac2_table_level; ///< Index for AC2 tables from AC2FRM element | |
316 //@} | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
317 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
318 } VC9Context; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
319 |
2482 | 320 /** |
321 * Get unary code of limited length | |
322 * @fixme FIXME Slow and ugly | |
323 * @param gb GetBitContext | |
324 * @param[in] stop The bitstop value (unary code of 1's or 0's) | |
325 * @param[in] len Maximum length | |
326 * @return Unary length/index | |
327 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
328 static int get_prefix(GetBitContext *gb, int stop, int len) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
329 { |
2462 | 330 #if 1 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
331 int i = 0, tmp = !stop; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
332 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
333 while (i != len && tmp != stop) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
334 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
335 tmp = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
336 i++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
337 } |
2483 | 338 if (i == len && tmp != stop) return len+1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
339 return i; |
2462 | 340 #else |
341 unsigned int buf; | |
342 int log; | |
343 | |
344 OPEN_READER(re, gb); | |
345 UPDATE_CACHE(re, gb); | |
346 buf=GET_CACHE(re, gb); //Still not sure | |
347 if (stop) buf = ~buf; | |
348 | |
349 log= av_log2(-buf); //FIXME: -? | |
350 if (log < limit){ | |
351 LAST_SKIP_BITS(re, gb, log+1); | |
352 CLOSE_READER(re, gb); | |
353 return log; | |
354 } | |
355 | |
356 LAST_SKIP_BITS(re, gb, limit); | |
357 CLOSE_READER(re, gb); | |
358 return limit; | |
359 #endif | |
360 } | |
361 | |
2482 | 362 /** |
363 * Init VC-9 specific tables and VC9Context members | |
364 * @param v The VC9Context to initialize | |
365 * @return Status | |
366 */ | |
2474 | 367 static int vc9_init_common(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
368 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
369 static int done = 0; |
2483 | 370 int i = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
371 |
2462 | 372 /* Set the bit planes */ |
373 v->mv_type_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
374 v->direct_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
375 v->skip_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
376 #if HAS_ADVANCED_PROFILE |
2462 | 377 v->ac_pred_plane = v->over_flags_plane = (struct BitPlane) { NULL, 0, 0, 0 }; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
378 v->hrd_rate = v->hrd_buffer = NULL; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
379 #endif |
2462 | 380 |
381 /* VLC tables */ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
382 #if 0 // spec -> actual tables converter |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
383 for(i=0; i<64; i++){ |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
384 int code= (vc9_norm6_spec[i][1] << vc9_norm6_spec[i][4]) + vc9_norm6_spec[i][3]; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
385 av_log(NULL, AV_LOG_DEBUG, "0x%03X, ", code); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
386 if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
387 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
388 for(i=0; i<64; i++){ |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
389 int code= vc9_norm6_spec[i][2] + vc9_norm6_spec[i][4]; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
390 av_log(NULL, AV_LOG_DEBUG, "%2d, ", code); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
391 if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
392 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
393 #endif |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
394 if(!done) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
395 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
396 done = 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
397 INIT_VLC(&vc9_bfraction_vlc, VC9_BFRACTION_VLC_BITS, 23, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
398 vc9_bfraction_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
399 vc9_bfraction_codes, 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
400 INIT_VLC(&vc9_norm2_vlc, VC9_NORM2_VLC_BITS, 4, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
401 vc9_norm2_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
402 vc9_norm2_codes, 1, 1, 1); |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
403 INIT_VLC(&vc9_norm6_vlc, VC9_NORM6_VLC_BITS, 64, |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
404 vc9_norm6_bits, 1, 1, |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
405 vc9_norm6_codes, 2, 2, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
406 INIT_VLC(&vc9_imode_vlc, VC9_IMODE_VLC_BITS, 7, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
407 vc9_imode_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
408 vc9_imode_codes, 1, 1, 1); |
2462 | 409 for (i=0; i<3; i++) |
410 { | |
411 INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16, | |
412 vc9_ttmb_bits[i], 1, 1, | |
413 vc9_ttmb_codes[i], 2, 2, 1); | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
414 INIT_VLC(&vc9_ttblk_vlc[i], VC9_TTBLK_VLC_BITS, 8, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
415 vc9_ttblk_bits[i], 1, 1, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
416 vc9_ttblk_codes[i], 1, 1, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
417 INIT_VLC(&vc9_subblkpat_vlc[i], VC9_SUBBLKPAT_VLC_BITS, 15, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
418 vc9_subblkpat_bits[i], 1, 1, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
419 vc9_subblkpat_codes[i], 1, 1, 1); |
2462 | 420 } |
421 for(i=0; i<4; i++) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
422 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
423 INIT_VLC(&vc9_4mv_block_pattern_vlc[i], VC9_4MV_BLOCK_PATTERN_VLC_BITS, 16, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
424 vc9_4mv_block_pattern_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
425 vc9_4mv_block_pattern_codes[i], 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
426 INIT_VLC(&vc9_cbpcy_p_vlc[i], VC9_CBPCY_P_VLC_BITS, 64, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
427 vc9_cbpcy_p_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
428 vc9_cbpcy_p_codes[i], 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
429 INIT_VLC(&vc9_mv_diff_vlc[i], VC9_MV_DIFF_VLC_BITS, 73, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
430 vc9_mv_diff_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
431 vc9_mv_diff_codes[i], 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
432 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
433 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
434 |
2462 | 435 /* Other defaults */ |
436 v->pq = -1; | |
437 v->mvrange = 0; /* 7.1.1.18, p80 */ | |
438 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
439 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
440 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
441 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
442 #if HAS_ADVANCED_PROFILE |
2482 | 443 /** |
444 * Decode sequence header's Hypothetic Reference Decoder data | |
445 * @see 6.2.1, p32 | |
446 * @param v The VC9Context to initialize | |
447 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
448 * @return Status | |
449 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
450 static int decode_hrd(VC9Context *v, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
451 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
452 int i, num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
453 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
454 num = get_bits(gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
455 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
456 if (v->hrd_rate || num != v->hrd_num_leaky_buckets) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
457 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
458 av_freep(&v->hrd_rate); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
459 } |
2462 | 460 if (!v->hrd_rate) v->hrd_rate = av_malloc(num*sizeof(uint16_t)); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
461 if (!v->hrd_rate) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
462 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
463 if (v->hrd_buffer || num != v->hrd_num_leaky_buckets) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
464 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
465 av_freep(&v->hrd_buffer); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
466 } |
2462 | 467 if (!v->hrd_buffer) v->hrd_buffer = av_malloc(num*sizeof(uint16_t)); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
468 if (!v->hrd_buffer) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
469 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
470 v->hrd_num_leaky_buckets = num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
471 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
472 //exponent in base-2 for rate |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
473 v->bit_rate_exponent = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
474 //exponent in base-2 for buffer_size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
475 v->buffer_size_exponent = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
476 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
477 for (i=0; i<num; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
478 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
479 //mantissae, ordered (if not, use a function ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
480 v->hrd_rate[i] = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
481 if (i && v->hrd_rate[i-1]>=v->hrd_rate[i]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
482 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
483 av_log(v->s.avctx, AV_LOG_ERROR, "HDR Rates aren't strictly increasing:" |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
484 "%i vs %i\n", v->hrd_rate[i-1], v->hrd_rate[i]); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
485 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
486 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
487 v->hrd_buffer[i] = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
488 if (i && v->hrd_buffer[i-1]<v->hrd_buffer[i]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
489 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
490 av_log(v->s.avctx, AV_LOG_ERROR, "HDR Buffers aren't decreasing:" |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
491 "%i vs %i\n", v->hrd_buffer[i-1], v->hrd_buffer[i]); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
492 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
493 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
494 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
495 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
496 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
497 |
2482 | 498 /** |
499 * Decode sequence header for Advanced Profile | |
500 * @see Table 2, p18 | |
501 * @see 6.1.7, pp21-27 | |
502 * @param v The VC9Context to initialize | |
503 * @param gb A GetBitContext initialized from AVCodecContext extra_data | |
504 * @return Status | |
505 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
506 static int decode_advanced_sequence_header(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
507 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
508 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
509 int nr, dr, aspect_ratio; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
510 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
511 v->postprocflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
512 v->broadcast = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
513 v->interlace = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
514 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
515 v->tfcntrflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
516 v->finterpflag = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
517 v->panscanflag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
518 v->reserved = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
519 if (v->reserved) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
520 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
521 av_log(avctx, AV_LOG_ERROR, "RESERVED should be 0 (is %i)\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
522 v->reserved); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
523 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
524 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
525 if (v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
526 v->extended_dmv = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
527 |
2462 | 528 /* 6.1.7, p21 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
529 if (get_bits(gb, 1) /* pic_size_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
530 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
531 avctx->coded_width = get_bits(gb, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
532 avctx->coded_height = get_bits(gb, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
533 if ( get_bits(gb, 1) /* disp_size_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
534 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
535 avctx->width = get_bits(gb, 14); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
536 avctx->height = get_bits(gb, 14); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
537 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
538 |
2462 | 539 /* 6.1.7.4, p22 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
540 if ( get_bits(gb, 1) /* aspect_ratio_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
541 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
542 aspect_ratio = get_bits(gb, 4); //SAR |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
543 if (aspect_ratio == 0x0F) //FF_ASPECT_EXTENDED |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
544 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
545 avctx->sample_aspect_ratio.num = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
546 avctx->sample_aspect_ratio.den = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
547 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
548 else if (aspect_ratio == 0x0E) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
549 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
550 av_log(avctx, AV_LOG_DEBUG, "Reserved AR found\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
551 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
552 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
553 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
554 avctx->sample_aspect_ratio = vc9_pixel_aspect[aspect_ratio]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
555 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
556 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
557 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
558 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
559 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
560 avctx->coded_width = avctx->width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
561 avctx->coded_height = avctx->height; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
562 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
563 |
2462 | 564 /* 6.1.8, p23 */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
565 if ( !get_bits(gb, 1) /* framerateflag */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
566 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
567 if ( get_bits(gb, 1) /* framerateind */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
568 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
569 nr = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
570 dr = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
571 if (nr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
572 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
573 av_log(avctx, AV_LOG_ERROR, "0 is forbidden for FRAMERATENR\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
574 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
575 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
576 if (nr>5) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
577 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
578 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
579 "Reserved FRAMERATENR %i not handled\n", nr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
580 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
581 if (dr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
582 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
583 av_log(avctx, AV_LOG_ERROR, "0 is forbidden for FRAMERATEDR\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
584 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
585 if (dr>2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
586 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
587 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
588 "Reserved FRAMERATEDR %i not handled\n", dr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
589 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
590 avctx->frame_rate_base = fps_nr[dr]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
591 avctx->frame_rate = fps_nr[nr]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
592 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
593 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
594 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
595 nr = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
596 // 0.03125->2048Hz / 0.03125Hz |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
597 avctx->frame_rate = 1000000; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
598 avctx->frame_rate_base = 31250*(1+nr); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
599 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
600 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
601 |
2462 | 602 /* 6.1.9, p25 */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
603 if ( get_bits(gb, 1) /* color_format_flag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
604 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
605 //Chromacity coordinates of color primaries |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
606 //like ITU-R BT.709-2, BT.470-2, ... |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
607 v->color_prim = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
608 if (v->color_prim<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
609 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
610 av_log(avctx, AV_LOG_ERROR, "0 for COLOR_PRIM is reserved\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
611 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
612 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
613 if (v->color_prim == 3 || v->color_prim>6) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
614 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
615 av_log(avctx, AV_LOG_DEBUG, "Reserved COLOR_PRIM %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
616 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
617 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
618 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
619 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
620 //Opto-electronic transfer characteristics |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
621 v->transfer_char = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
622 if (v->transfer_char == 3 || v->transfer_char>8) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
623 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
624 av_log(avctx, AV_LOG_DEBUG, "Reserved TRANSFERT_CHAR %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
625 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
626 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
627 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
628 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
629 //Matrix coefficient for primariev->YCbCr |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
630 v->matrix_coef = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
631 if (v->matrix_coef < 1) return -1; //forbidden |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
632 if ((v->matrix_coef>3 && v->matrix_coef<6) || v->matrix_coef>7) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
633 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
634 av_log(avctx, AV_LOG_DEBUG, "Reserved MATRIX_COEF %i found\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
635 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
636 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
637 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
638 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
639 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
640 //Hypothetical reference decoder indicator flag |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
641 v->hrd_param_flag = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
642 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
643 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
644 if (decode_hrd(v, gb) < 0) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
645 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
646 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
647 av_log(avctx, AV_LOG_DEBUG, "Advanced profile not supported yet\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
648 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
649 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
650 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
651 |
2482 | 652 /** |
653 * Decode Simple/Main Profiles sequence header | |
654 * @see Figure 7-8, p16-17 | |
655 * @param avctx Codec context | |
656 * @param gb GetBit context initialized from Codec context extra_data | |
657 * @return Status | |
658 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
659 static int decode_sequence_header(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
660 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
661 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
662 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
663 av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits(gb, 32)); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
664 v->profile = get_bits(gb, 2); |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
665 if (v->profile == 2) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
666 av_log(avctx, AV_LOG_ERROR, "Profile 2 is reserved\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
667 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
668 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
669 if (v->profile == PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
670 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
671 v->level = get_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
672 v->chromaformat = get_bits(gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
673 if (v->chromaformat != 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
674 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
675 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
676 "Only 4:2:0 chroma format supported\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
677 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
678 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
679 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
680 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
681 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
682 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
683 v->res_sm = get_bits(gb, 2); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
684 if (v->res_sm) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
685 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
686 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
687 "Reserved RES_SM=%i is forbidden\n", v->res_sm); |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
688 return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
689 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
690 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
691 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
692 // (fps-2)/4 (->30) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
693 v->frmrtq_postproc = get_bits(gb, 3); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
694 // (bitrate-32kbps)/64kbps |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
695 v->bitrtq_postproc = get_bits(gb, 5); //common |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
696 v->s.loop_filter = get_bits(gb, 1); //common |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
697 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
698 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
699 if (v->profile < PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
700 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
701 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
702 v->res_x8 = get_bits(gb, 1); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
703 if (v->res_x8) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
704 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
705 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
706 "1 for reserved RES_X8 is forbidden\n"); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
707 //return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
708 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
709 v->multires = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
710 v->res_fasttx = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
711 if (!v->res_fasttx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
712 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
713 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
714 "0 for reserved RES_FASTTX is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
715 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
716 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
717 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
718 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
719 v->fastuvmc = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
720 if (!v->profile && !v->fastuvmc) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
721 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
722 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
723 "FASTUVMC unavailable in Simple Profile\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
724 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
725 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
726 v->extended_mv = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
727 if (!v->profile && v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
728 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
729 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
730 "Extended MVs unavailable in Simple Profile\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
731 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
732 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
733 v->dquant = get_bits(gb, 2); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
734 v->vstransform = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
735 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
736 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
737 if (v->profile < PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
738 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
739 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
740 v->res_transtab = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
741 if (v->res_transtab) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
742 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
743 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
744 "1 for reserved RES_TRANSTAB is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
745 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
746 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
747 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
748 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
749 v->overlap = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
750 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
751 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
752 if (v->profile < PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
753 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
754 { |
2474 | 755 v->s.resync_marker = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
756 v->rangered = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
757 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
758 |
2474 | 759 v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
760 v->quantizer_mode = get_bits(gb, 2); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
761 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
762 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
763 if (v->profile < PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
764 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
765 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
766 v->finterpflag = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
767 v->res_rtm_flag = get_bits(gb, 1); //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
768 if (!v->res_rtm_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
769 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
770 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
771 "0 for reserved RES_RTM_FLAG is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
772 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
773 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
774 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
775 av_log(avctx, AV_LOG_INFO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
776 "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
777 "LoopFilter=%i, MultiRes=%i, FastUVMV=%i, Extended MV=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
778 "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
779 "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
780 v->profile, v->frmrtq_postproc, v->bitrtq_postproc, |
2482 | 781 v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, |
2474 | 782 v->rangered, v->vstransform, v->overlap, v->s.resync_marker, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
783 v->dquant, v->quantizer_mode, avctx->max_b_frames |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
784 ); |
2462 | 785 return 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
786 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
787 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
788 #if HAS_ADVANCED_PROFILE |
2462 | 789 else return decode_advanced_sequence_header(avctx, gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
790 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
791 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
792 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
793 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
794 #if HAS_ADVANCED_PROFILE |
2482 | 795 /** Entry point decoding (Advanced Profile) |
796 * @param avctx Codec context | |
797 * @param gb GetBit context initialized from avctx->extra_data | |
798 * @return Status | |
799 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
800 static int advanced_entry_point_process(AVCodecContext *avctx, GetBitContext *gb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
801 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
802 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
803 int range_mapy_flag, range_mapuv_flag, i; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
804 if (v->profile != PROFILE_ADVANCED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
805 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
806 av_log(avctx, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
807 "Entry point are only defined in Advanced Profile!\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
808 return -1; //Only for advanced profile! |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
809 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
810 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
811 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
812 //Update buffer fullness |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
813 av_log(avctx, AV_LOG_DEBUG, "Buffer fullness update\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
814 for (i=0; i<v->hrd_num_leaky_buckets; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
815 skip_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
816 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
817 if ((range_mapy_flag = get_bits(gb, 1))) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
818 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
819 //RANGE_MAPY |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
820 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPY\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
821 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
822 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
823 if ((range_mapuv_flag = get_bits(gb, 1))) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
824 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
825 //RANGE_MAPUV |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
826 av_log(avctx, AV_LOG_DEBUG, "RANGE_MAPUV\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
827 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
828 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
829 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
830 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
831 //NUMPANSCANWIN |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
832 v->numpanscanwin = get_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
833 av_log(avctx, AV_LOG_DEBUG, "NUMPANSCANWIN: %u\n", v->numpanscanwin); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
834 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
835 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
836 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
837 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
838 |
2482 | 839 /***********************************************************************/ |
840 /** | |
841 * @defgroup bitplane VC9 Bitplane decoding | |
842 * @see 8.7, p56 | |
843 * @{ | |
844 */ | |
845 | |
846 /** @addtogroup bitplane | |
847 * Imode types | |
848 * @{ | |
849 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
850 #define IMODE_RAW 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
851 #define IMODE_NORM2 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
852 #define IMODE_DIFF2 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
853 #define IMODE_NORM6 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
854 #define IMODE_DIFF6 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
855 #define IMODE_ROWSKIP 5 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
856 #define IMODE_COLSKIP 6 |
2482 | 857 /** @} */ //imode defines |
858 | |
859 /** Allocate the buffer from a bitplane, given its dimensions | |
860 * @param bp Bitplane which buffer is to allocate | |
861 * @param[in] width Width of the buffer | |
862 * @param[in] height Height of the buffer | |
863 * @return Status | |
864 * @todo TODO: Take into account stride | |
865 * @todo TODO: Allow use of external buffers ? | |
866 */ | |
2462 | 867 int alloc_bitplane(BitPlane *bp, int width, int height) |
868 { | |
869 if (!bp || bp->width<0 || bp->height<0) return -1; | |
870 bp->data = (uint8_t*)av_malloc(width*height); | |
871 if (!bp->data) return -1; | |
2482 | 872 bp->width = bp->stride = width; |
2462 | 873 bp->height = height; |
874 return 0; | |
875 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
876 |
2482 | 877 /** Free the bitplane's buffer |
878 * @param bp Bitplane which buffer is to free | |
879 */ | |
2474 | 880 void free_bitplane(BitPlane *bp) |
881 { | |
882 bp->width = bp->stride = bp->height = 0; | |
883 if (bp->data) av_freep(&bp->data); | |
884 } | |
885 | |
2482 | 886 /** Decode rows by checking if they are skiped |
887 * @param plane Buffer to store decoded bits | |
888 * @param[in] width Width of this buffer | |
889 * @param[in] height Height of this buffer | |
890 * @param[in] stride of this buffer | |
891 */ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
892 static void decode_rowskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){ |
2459 | 893 int x, y; |
894 | |
895 for (y=0; y<height; y++){ | |
2474 | 896 if (!get_bits(gb, 1)) //rowskip |
2459 | 897 memset(plane, 0, width); |
898 else | |
899 for (x=0; x<width; x++) | |
2474 | 900 plane[x] = get_bits(gb, 1); |
2459 | 901 plane += stride; |
902 } | |
903 } | |
904 | |
2482 | 905 /** Decode columns by checking if they are skiped |
906 * @param plane Buffer to store decoded bits | |
907 * @param[in] width Width of this buffer | |
908 * @param[in] height Height of this buffer | |
909 * @param[in] stride of this buffer | |
910 * @fixme FIXME: Optimize | |
911 */ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
912 static void decode_colskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){ |
2459 | 913 int x, y; |
914 | |
915 for (x=0; x<width; x++){ | |
2474 | 916 if (!get_bits(gb, 1)) //colskip |
2459 | 917 for (y=0; y<height; y++) |
918 plane[y*stride] = 0; | |
919 else | |
920 for (y=0; y<height; y++) | |
2474 | 921 plane[y*stride] = get_bits(gb, 1); |
2459 | 922 plane ++; |
923 } | |
924 } | |
925 | |
2482 | 926 /** Decode a bitplane's bits |
927 * @param bp Bitplane where to store the decode bits | |
928 * @param v VC9 context for bit reading and logging | |
929 * @return Status | |
930 * @fixme FIXME: Optimize | |
931 * @todo TODO: Decide if a struct is needed | |
932 */ | |
2462 | 933 static int bitplane_decoding(BitPlane *bp, VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
934 { |
2474 | 935 GetBitContext *gb = &v->s.gb; |
936 | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
937 int imode, x, y, code, use_vertical_tile, tile_w, tile_h, offset; |
2462 | 938 uint8_t invert, *planep = bp->data; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
939 |
2474 | 940 invert = get_bits(gb, 1); |
941 imode = get_vlc2(gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
942 |
2462 | 943 bp->is_raw = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
944 switch (imode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
945 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
946 case IMODE_RAW: |
2462 | 947 //Data is actually read in the MB layer (same for all tests == "raw") |
948 bp->is_raw = 1; //invert ignored | |
949 return invert; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
950 case IMODE_DIFF2: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
951 case IMODE_NORM2: |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
952 if ((bp->height*bp->width) & 1) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
953 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
954 *(++planep) = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
955 offset = x = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
956 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
957 else offset = x = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
958 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
959 for (y=0; y<bp->height; y++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
960 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
961 for(; x<bp->width; x+=2) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
962 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
963 code = get_vlc2(gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
964 *(++planep) = code&1; //lsb => left |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
965 *(++planep) = (code>>1)&1; //msb => right |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
966 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
967 planep += bp->stride-bp->width; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
968 if ((bp->width-offset)&1) //Odd number previously processed |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
969 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
970 code = get_vlc2(gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
971 *planep = code&1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
972 planep += bp->stride-bp->width; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
973 *planep = (code>>1)&1; //msb => right |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
974 offset = x = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
975 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
976 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
977 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
978 offset = x = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
979 planep += bp->stride-bp->width; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
980 } |
2459 | 981 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
982 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
983 case IMODE_DIFF6: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
984 case IMODE_NORM6: |
2462 | 985 use_vertical_tile= bp->height%3==0 && bp->width%3!=0; |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
986 tile_w= use_vertical_tile ? 2 : 3; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
987 tile_h= use_vertical_tile ? 3 : 2; |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
988 |
2462 | 989 for(y= bp->height%tile_h; y< bp->height; y+=tile_h){ |
990 for(x= bp->width%tile_w; x< bp->width; x+=tile_w){ | |
2474 | 991 code = get_vlc2(gb, vc9_norm6_vlc.table, VC9_NORM6_VLC_BITS, 2); |
2463
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
992 if(code<0){ |
2482 | 993 av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); |
2463
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
994 return -1; |
9baa47d8297b
check norm6 vlc validity as there are some bit sequences which dont corespond to any codeword, the other vlc tables all seem to be huffman tables though
michael
parents:
2462
diff
changeset
|
995 } |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
996 //FIXME following is a pure guess and probably wrong |
2462 | 997 //FIXME A bitplane (0 | !0), so could the shifts be avoided ? |
998 planep[x + 0*bp->stride]= (code>>0)&1; | |
999 planep[x + 1 + 0*bp->stride]= (code>>1)&1; | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1000 //FIXME Does branch prediction help here? |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1001 if(use_vertical_tile){ |
2462 | 1002 planep[x + 0 + 1*bp->stride]= (code>>2)&1; |
1003 planep[x + 1 + 1*bp->stride]= (code>>3)&1; | |
1004 planep[x + 0 + 2*bp->stride]= (code>>4)&1; | |
1005 planep[x + 1 + 2*bp->stride]= (code>>5)&1; | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1006 }else{ |
2462 | 1007 planep[x + 2 + 0*bp->stride]= (code>>2)&1; |
1008 planep[x + 0 + 1*bp->stride]= (code>>3)&1; | |
1009 planep[x + 1 + 1*bp->stride]= (code>>4)&1; | |
1010 planep[x + 2 + 1*bp->stride]= (code>>5)&1; | |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1011 } |
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1012 } |
2459 | 1013 } |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1014 |
2462 | 1015 x= bp->width % tile_w; |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1016 decode_colskip(bp->data , x, bp->height , bp->stride, &v->s.gb); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1017 decode_rowskip(bp->data+x, bp->width - x, bp->height % tile_h, bp->stride, &v->s.gb); |
2460
42077bb89a53
norm-6 / diff-6 support (untested, parts of it just guessed as the spec is unclear)
michael
parents:
2459
diff
changeset
|
1018 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1019 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1020 case IMODE_ROWSKIP: |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1021 decode_rowskip(bp->data, bp->width, bp->height, bp->stride, &v->s.gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1022 break; |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1023 case IMODE_COLSKIP: |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1024 decode_colskip(bp->data, bp->width, bp->height, bp->stride, &v->s.gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1025 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1026 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1027 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1028 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1029 /* Applying diff operator */ |
2459 | 1030 if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1031 { |
2462 | 1032 planep = bp->data; |
2459 | 1033 planep[0] ^= invert; |
2462 | 1034 for (x=1; x<bp->width; x++) |
2459 | 1035 planep[x] ^= planep[x-1]; |
2462 | 1036 for (y=1; y<bp->height; y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1037 { |
2462 | 1038 planep += bp->stride; |
1039 planep[0] ^= planep[-bp->stride]; | |
1040 for (x=1; x<bp->width; x++) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1041 { |
2462 | 1042 if (planep[x-1] != planep[x-bp->stride]) planep[x] ^= invert; |
1043 else planep[x] ^= planep[x-1]; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1044 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1045 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1046 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1047 else if (invert) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1048 { |
2462 | 1049 planep = bp->data; |
1050 for (x=0; x<bp->width*bp->height; x++) planep[x] = !planep[x]; //FIXME stride | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1051 } |
2462 | 1052 return (imode<<1) + invert; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1053 } |
2482 | 1054 /** @} */ //Bitplane group |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1055 |
2482 | 1056 /***********************************************************************/ |
1057 /** VOP Dquant decoding | |
1058 * @param v VC9 Context | |
1059 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1060 static int vop_dquant_decoding(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1061 { |
2474 | 1062 GetBitContext *gb = &v->s.gb; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1063 int pqdiff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1064 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1065 //variable size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1066 if (v->dquant == 2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1067 { |
2474 | 1068 pqdiff = get_bits(gb, 3); |
1069 if (pqdiff == 7) v->altpq = get_bits(gb, 5); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1070 else v->altpq = v->pq + pqdiff + 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1071 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1072 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1073 { |
2474 | 1074 v->dquantfrm = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1075 if ( v->dquantfrm ) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1076 { |
2474 | 1077 v->dqprofile = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1078 switch (v->dqprofile) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1079 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1080 case DQPROFILE_SINGLE_EDGE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1081 case DQPROFILE_DOUBLE_EDGES: |
2474 | 1082 v->dqsbedge = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1083 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1084 case DQPROFILE_ALL_MBS: |
2474 | 1085 v->dqbilevel = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1086 default: break; //Forbidden ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1087 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1088 if (!v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1089 { |
2474 | 1090 pqdiff = get_bits(gb, 3); |
1091 if (pqdiff == 7) v->altpq = get_bits(gb, 5); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1092 else v->altpq = v->pq + pqdiff + 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1093 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1094 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1095 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1096 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1097 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1098 |
2482 | 1099 /***********************************************************************/ |
1100 /** | |
1101 * @defgroup all_frame_hdr All VC9 profiles frame header | |
1102 * @brief Part of the frame header decoding from all profiles | |
1103 * @warning Only pro/epilog differs between Simple/Main and Advanced => check caller | |
1104 * @{ | |
1105 */ | |
1106 /** B and BI frame header decoding, primary part | |
1107 * @see Tables 11+12, p62-65 | |
1108 * @param v VC9 context | |
1109 * @return Status | |
1110 * @warning Also handles BI frames | |
1111 */ | |
2474 | 1112 static int decode_b_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1113 { |
2474 | 1114 GetBitContext *gb = &v->s.gb; |
2483 | 1115 int pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1116 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1117 /* Prolog common to all frametypes should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1118 if (v->profile == PROFILE_SIMPLE) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1119 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1120 av_log(v->s.avctx, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1121 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1122 } |
2474 | 1123 v->bfraction = vc9_bfraction_lut[get_vlc2(gb, vc9_bfraction_vlc.table, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1124 VC9_BFRACTION_VLC_BITS, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1125 if (v->bfraction < -1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1126 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1127 av_log(v->s.avctx, AV_LOG_ERROR, "Invalid BFRaction\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1128 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1129 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1130 else if (!v->bfraction) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1131 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1132 /* We actually have a BI frame */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1133 v->s.pict_type = BI_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1134 v->buffer_fullness = get_bits(gb, 7); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1135 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1136 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1137 /* Read the quantization stuff */ |
2474 | 1138 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1139 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1140 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1141 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1142 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1143 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1144 } |
2474 | 1145 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1146 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1147 v->pquantizer = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1148 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1149 if (v->profile == PROFILE_ADVANCED) |
2483 | 1150 { |
1151 if (v->postprocflag) v->postproc = get_bits(gb, 2); | |
1152 if (v->extended_mv == 1 && v->s.pict_type != BI_TYPE) | |
1153 v->mvrange = get_prefix(gb, 0, 3); | |
1154 } | |
1155 else | |
1156 { | |
1157 if (v->extended_mv == 1) | |
1158 v->mvrange = get_prefix(gb, 0, 3); | |
1159 } | |
1160 /* Read the MV mode */ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1161 if (v->s.pict_type != BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1162 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1163 v->mv_mode = get_bits(gb, 1); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1164 if (v->pq < 13) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1165 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1166 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1167 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1168 v->mv_mode = get_bits(gb, 2); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1169 if (v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1170 av_log(v->s.avctx, AV_LOG_ERROR, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1171 "mv_mode for lowquant B frame was %i\n", v->mv_mode); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1172 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1173 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1174 else |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1175 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1176 if (!v->mv_mode) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1177 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1178 if (get_bits(gb, 1)) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1179 av_log(v->s.avctx, AV_LOG_ERROR, |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1180 "mv_mode for highquant B frame was %i\n", v->mv_mode); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1181 } |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1182 v->mv_mode = 1-v->mv_mode; //To match (pq < 13) mapping |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1183 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1184 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1185 |
2474 | 1186 return 0; |
1187 } | |
1188 | |
2482 | 1189 /** B and BI frame header decoding, secondary part |
1190 * @see Tables 11+12, p62-65 | |
1191 * @param v VC9 context | |
1192 * @return Status | |
1193 * @warning Also handles BI frames | |
1194 * @warning To call once all MB arrays are allocated | |
2483 | 1195 * @todo Support Advanced Profile headers |
2482 | 1196 */ |
2474 | 1197 static int decode_b_picture_secondary_header(VC9Context *v) |
1198 { | |
1199 GetBitContext *gb = &v->s.gb; | |
1200 int status; | |
1201 | |
2483 | 1202 status = bitplane_decoding(&v->skip_mb_plane, v); |
2474 | 1203 if (status < 0) return -1; |
1204 #if TRACE | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1205 if (v->mv_mode == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1206 { |
2462 | 1207 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1208 if (status < 0) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1209 return -1; |
2462 | 1210 #if TRACE |
2474 | 1211 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1212 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1213 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1214 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1215 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1216 //bitplane |
2462 | 1217 status = bitplane_decoding(&v->direct_mb_plane, v); |
1218 if (status < 0) return -1; | |
1219 #if TRACE | |
2474 | 1220 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct plane encoding: " |
2462 | 1221 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1222 #endif | |
1223 | |
2474 | 1224 av_log(v->s.avctx, AV_LOG_DEBUG, "Skip MB plane encoding: " |
2462 | 1225 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1226 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1227 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1228 /* FIXME: what is actually chosen for B frames ? */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1229 v->s.mv_table_index = get_bits(gb, 2); //but using vc9_ tables |
2474 | 1230 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)]; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1231 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1232 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1233 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1234 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1235 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1236 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1237 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1238 { |
2474 | 1239 v->ttmbf = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1240 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1241 { |
2474 | 1242 v->ttfrm = get_bits(gb, 2); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1243 av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n", |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1244 (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1245 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1246 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1247 /* Epilog (AC/DC syntax) should be done in caller */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1248 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1249 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1250 |
2482 | 1251 /** I frame header decoding, primary part |
1252 * @see Tables 5+7, p53-54 and 55-57 | |
1253 * @param v VC9 context | |
1254 * @return Status | |
2483 | 1255 * @todo Support Advanced Profile headers |
2482 | 1256 */ |
2483 | 1257 static int decode_i_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1258 { |
2474 | 1259 GetBitContext *gb = &v->s.gb; |
2483 | 1260 int pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1261 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1262 /* Prolog common to all frametypes should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1263 //BF = Buffer Fullness |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1264 if (v->profile < PROFILE_ADVANCED && get_bits(gb, 7)) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1265 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1266 av_log(v->s.avctx, AV_LOG_DEBUG, "I BufferFullness not 0\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1267 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1268 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1269 /* Quantizer stuff */ |
2474 | 1270 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1271 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1272 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1273 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1274 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1275 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1276 } |
2474 | 1277 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1278 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1279 v->pquantizer = get_bits(gb, 1); |
1280 av_log(v->s.avctx, AV_LOG_DEBUG, "I frame: QP=%i (+%i/2)\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1281 v->pq, v->halfpq); |
2483 | 1282 return 0; |
1283 } | |
1284 | |
1285 /** I frame header decoding, secondary part | |
1286 * @param v VC9 context | |
1287 * @return Status | |
1288 * @todo Support Advanced Profile headers | |
1289 */ | |
1290 static int decode_i_picture_secondary_header(VC9Context *v) | |
1291 { | |
1292 int status; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1293 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1294 if (v->profile == PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1295 { |
2483 | 1296 v->s.ac_pred = get_bits(&v->s.gb, 1); |
1297 if (v->postprocflag) v->postproc = get_bits(&v->s.gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1298 /* 7.1.1.34 + 8.5.2 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1299 if (v->overlap && v->pq<9) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1300 { |
2483 | 1301 v->condover = get_bits(&v->s.gb, 1); |
2462 | 1302 if (v->condover) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1303 { |
2483 | 1304 v->condover = 2+get_bits(&v->s.gb, 1); |
2462 | 1305 if (v->condover == 3) |
1306 { | |
1307 status = bitplane_decoding(&v->over_flags_plane, v); | |
1308 if (status < 0) return -1; | |
2483 | 1309 # if TRACE |
2474 | 1310 av_log(v->s.avctx, AV_LOG_DEBUG, "Overflags plane encoding: " |
2462 | 1311 "Imode: %i, Invert: %i\n", status>>1, status&1); |
2483 | 1312 # endif |
2462 | 1313 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1314 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1315 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1316 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1317 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1318 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1319 /* Epilog (AC/DC syntax) should be done in caller */ |
2483 | 1320 return 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1321 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1322 |
2482 | 1323 /** P frame header decoding, primary part |
1324 * @see Tables 5+7, p53-54 and 55-57 | |
1325 * @param v VC9 context | |
2483 | 1326 * @todo Support Advanced Profile headers |
2482 | 1327 * @return Status |
1328 */ | |
2474 | 1329 static int decode_p_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1330 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1331 /* INTERFRM, FRMCNT, RANGEREDFRM read in caller */ |
2474 | 1332 GetBitContext *gb = &v->s.gb; |
2483 | 1333 int lowquant, pqindex; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1334 |
2474 | 1335 pqindex = get_bits(gb, 5); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1336 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1337 v->pq = pquant_table[0][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1338 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1339 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1340 v->pq = pquant_table[v->quantizer_mode-1][pqindex]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1341 } |
2474 | 1342 if (pqindex < 9) v->halfpq = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1343 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
2474 | 1344 v->pquantizer = get_bits(gb, 1); |
1345 av_log(v->s.avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1346 v->pq, v->halfpq); |
2474 | 1347 if (v->extended_mv == 1) v->mvrange = get_prefix(gb, 0, 3); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1348 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1349 if (v->profile == PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1350 { |
2474 | 1351 if (v->postprocflag) v->postproc = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1352 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1353 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1354 #endif |
2474 | 1355 if (v->multires) v->respic = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1356 lowquant = (v->pquantizer>12) ? 0 : 1; |
2474 | 1357 v->mv_mode = mv_pmode_table[lowquant][get_prefix(gb, 1, 4)]; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1358 if (v->mv_mode == MV_PMODE_INTENSITY_COMP) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1359 { |
2474 | 1360 v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(gb, 1, 3)]; |
1361 v->lumscale = get_bits(gb, 6); | |
1362 v->lumshift = get_bits(gb, 6); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1363 } |
2474 | 1364 return 0; |
1365 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1366 |
2482 | 1367 /** P frame header decoding, secondary part |
1368 * @see Tables 5+7, p53-54 and 55-57 | |
1369 * @param v VC9 context | |
1370 * @warning To call once all MB arrays are allocated | |
1371 * @return Status | |
1372 */ | |
2474 | 1373 static int decode_p_picture_secondary_header(VC9Context *v) |
1374 { | |
1375 GetBitContext *gb = &v->s.gb; | |
1376 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1377 if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1378 v->mv_mode2 == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1379 || v->mv_mode == MV_PMODE_MIXED_MV) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1380 { |
2462 | 1381 status = bitplane_decoding(&v->mv_type_mb_plane, v); |
1382 if (status < 0) return -1; | |
1383 #if TRACE | |
2474 | 1384 av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " |
2462 | 1385 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1386 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1387 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1388 |
2462 | 1389 status = bitplane_decoding(&v->skip_mb_plane, v); |
1390 if (status < 0) return -1; | |
1391 #if TRACE | |
2474 | 1392 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " |
2462 | 1393 "Imode: %i, Invert: %i\n", status>>1, status&1); |
1394 #endif | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1395 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1396 /* Hopefully this is correct for P frames */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1397 v->s.mv_table_index =get_bits(gb, 2); //but using vc9_ tables |
2474 | 1398 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(gb, 2)]; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1399 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1400 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1401 { |
2474 | 1402 av_log(v->s.avctx, AV_LOG_INFO, "VOP DQuant info\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1403 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1404 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1405 |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1406 v->ttfrm = 0; //FIXME Is that so ? |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1407 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1408 { |
2474 | 1409 v->ttmbf = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1410 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1411 { |
2474 | 1412 v->ttfrm = get_bits(gb, 2); |
1413 av_log(v->s.avctx, AV_LOG_INFO, "Transform used: %ix%i\n", | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1414 (v->ttfrm & 2) ? 4 : 8, (v->ttfrm & 1) ? 4 : 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1415 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1416 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1417 /* Epilog (AC/DC syntax) should be done in caller */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1418 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1419 } |
2482 | 1420 /** @} */ //End of group all_frm_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1421 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1422 |
2482 | 1423 /***********************************************************************/ |
1424 /** | |
1425 * @defgroup std_frame_hdr VC9 Simple/Main Profiles header decoding | |
1426 * @brief Part of the frame header decoding belonging to Simple/Main Profiles | |
1427 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1428 * check caller | |
1429 * @{ | |
1430 */ | |
1431 | |
1432 /** Frame header decoding, first part, in Simple and Main profiles | |
1433 * @see Tables 5+7, p53-54 and 55-57 | |
1434 * @param v VC9 context | |
2483 | 1435 * @todo FIXME: RANGEREDFRM element not read if BI frame from Table6, P54 |
1436 * However, 7.1.1.8 says "all frame types, for main profiles" | |
2482 | 1437 * @return Status |
1438 */ | |
2474 | 1439 static int standard_decode_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1440 { |
2474 | 1441 GetBitContext *gb = &v->s.gb; |
1442 int status = 0; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1443 |
2474 | 1444 if (v->finterpflag) v->interpfrm = get_bits(gb, 1); |
1445 skip_bits(gb, 2); //framecnt unused | |
1446 if (v->rangered) v->rangeredfrm = get_bits(gb, 1); | |
1447 v->s.pict_type = get_bits(gb, 1); | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1448 if (v->s.avctx->max_b_frames) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1449 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1450 if (!v->s.pict_type) |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1451 { |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1452 if (get_bits(gb, 1)) v->s.pict_type = I_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1453 else v->s.pict_type = B_TYPE; |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1454 } |
2474 | 1455 else v->s.pict_type = P_TYPE; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1456 } |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1457 else v->s.pict_type++; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1458 |
2474 | 1459 switch (v->s.pict_type) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1460 { |
2483 | 1461 case I_TYPE: status = decode_i_picture_primary_header(v); break; |
2474 | 1462 case P_TYPE: status = decode_p_picture_primary_header(v); break; |
2483 | 1463 case BI_TYPE: //Same as B |
2474 | 1464 case B_TYPE: status = decode_b_picture_primary_header(v); break; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1465 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1466 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1467 if (status == FRAME_SKIPED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1468 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1469 av_log(v->s.avctx, AV_LOG_INFO, "Skipping frame...\n"); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1470 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1471 } |
2474 | 1472 return 0; |
1473 } | |
1474 | |
2482 | 1475 /** Frame header decoding, secondary part |
1476 * @param v VC9 context | |
1477 * @warning To call once all MB arrays are allocated | |
1478 * @return Status | |
1479 */ | |
2474 | 1480 static int standard_decode_picture_secondary_header(VC9Context *v) |
1481 { | |
1482 GetBitContext *gb = &v->s.gb; | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1483 int status = 0; |
2474 | 1484 |
1485 switch (v->s.pict_type) | |
1486 { | |
1487 case P_TYPE: status = decode_p_picture_secondary_header(v); break; | |
1488 case B_TYPE: status = decode_b_picture_secondary_header(v); break; | |
2483 | 1489 case BI_TYPE: |
1490 case I_TYPE: break; //Nothing needed as it's done in the epilog | |
2474 | 1491 } |
2483 | 1492 if (status < 0) return FRAME_SKIPED; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1493 |
2462 | 1494 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1495 v->ac_table_level = decode012(gb); |
2474 | 1496 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1497 { |
2482 | 1498 v->ac2_table_level = decode012(gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1499 } |
2462 | 1500 /* DC Syntax */ |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1501 v->s.dc_table_index = decode012(gb); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1502 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1503 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1504 } |
2482 | 1505 /** @} */ //End for group std_frame_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1506 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1507 #if HAS_ADVANCED_PROFILE |
2482 | 1508 /***********************************************************************/ |
1509 /** | |
1510 * @defgroup adv_frame_hdr VC9 Advanced Profile header decoding | |
1511 * @brief Part of the frame header decoding belonging to Advanced Profiles | |
1512 * @warning Only pro/epilog differs between Simple/Main and Advanced => | |
1513 * check caller | |
1514 * @{ | |
1515 */ | |
1516 /** Frame header decoding, primary part | |
1517 * @param v VC9 context | |
1518 * @return Status | |
1519 */ | |
2474 | 1520 static int advanced_decode_picture_primary_header(VC9Context *v) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1521 { |
2474 | 1522 GetBitContext *gb = &v->s.gb; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1523 static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE }; |
2483 | 1524 int type; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1525 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1526 if (v->interlace) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1527 { |
2474 | 1528 v->fcm = get_bits(gb, 1); |
1529 if (v->fcm) v->fcm = 2+get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1530 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1531 |
2474 | 1532 type = get_prefix(gb, 0, 4); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1533 if (type > 4 || type < 0) return FRAME_SKIPED; |
2474 | 1534 v->s.pict_type = type_table[type]; |
1535 av_log(v->s.avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->s.pict_type); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1536 |
2474 | 1537 if (v->tfcntrflag) v->tfcntr = get_bits(gb, 8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1538 if (v->broadcast) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1539 { |
2474 | 1540 if (!v->interlace) v->rptfrm = get_bits(gb, 2); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1541 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1542 { |
2474 | 1543 v->tff = get_bits(gb, 1); |
1544 v->rff = get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1545 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1546 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1547 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1548 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1549 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1550 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1551 for (i=0; i<v->numpanscanwin; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1552 { |
2474 | 1553 v->topleftx[i] = get_bits(gb, 16); |
1554 v->toplefty[i] = get_bits(gb, 16); | |
1555 v->bottomrightx[i] = get_bits(gb, 16); | |
1556 v->bottomrighty[i] = get_bits(gb, 16); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1557 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1558 #else |
2474 | 1559 skip_bits(gb, 16*4*v->numpanscanwin); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1560 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1561 } |
2474 | 1562 v->s.no_rounding = !get_bits(gb, 1); |
1563 v->uvsamp = get_bits(gb, 1); | |
1564 if (v->finterpflag == 1) v->interpfrm = get_bits(gb, 1); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1565 |
2474 | 1566 switch(v->s.pict_type) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1567 { |
2483 | 1568 case I_TYPE: if (decode_i_picture_primary_header(v) < 0) return -1; |
2474 | 1569 case P_TYPE: if (decode_p_picture_primary_header(v) < 0) return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1570 case BI_TYPE: |
2474 | 1571 case B_TYPE: if (decode_b_picture_primary_header(v) < 0) return FRAME_SKIPED; |
2483 | 1572 default: return -1; |
2474 | 1573 } |
1574 } | |
1575 | |
2482 | 1576 /** Frame header decoding, secondary part |
1577 * @param v VC9 context | |
1578 * @return Status | |
1579 */ | |
2474 | 1580 static int advanced_decode_picture_secondary_header(VC9Context *v) |
1581 { | |
1582 GetBitContext *gb = &v->s.gb; | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1583 int status = 0; |
2474 | 1584 |
1585 switch(v->s.pict_type) | |
1586 { | |
2483 | 1587 case P_TYPE: status = decode_p_picture_secondary_header(v); break; |
1588 case B_TYPE: status = decode_b_picture_secondary_header(v); break; | |
1589 case BI_TYPE: | |
1590 case I_TYPE: status = decode_i_picture_secondary_header(v); break; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1591 } |
2483 | 1592 if (status<0) return FRAME_SKIPED; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1593 |
2462 | 1594 /* AC Syntax */ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1595 v->ac_table_level = decode012(gb); |
2474 | 1596 if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1597 { |
2482 | 1598 v->ac2_table_level = decode012(gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1599 } |
2462 | 1600 /* DC Syntax */ |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1601 v->s.dc_table_index = decode012(gb); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1602 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1603 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1604 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1605 #endif |
2482 | 1606 /** @} */ //End for adv_frame_hdr |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1607 |
2482 | 1608 /***********************************************************************/ |
1609 /** | |
1610 * @defgroup block VC9 Block-level functions | |
1611 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 | |
1612 * @todo TODO: Integrate to MpegEncContext facilities | |
1613 * @{ | |
1614 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1615 |
2482 | 1616 /** |
1617 * @def GET_MQUANT | |
1618 * @brief Get macroblock-level quantizer scale | |
1619 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1620 #define GET_MQUANT() \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1621 if (v->dquantfrm) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1622 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1623 if (v->dqprofile == DQPROFILE_ALL_MBS) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1624 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1625 if (v->dqbilevel) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1626 { \ |
2474 | 1627 mquant = (get_bits(gb, 1)) ? v->pq : v->altpq; \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1628 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1629 else \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1630 { \ |
2474 | 1631 mqdiff = get_bits(gb, 3); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1632 if (mqdiff != 7) mquant = v->pq + mqdiff; \ |
2474 | 1633 else mquant = get_bits(gb, 5); \ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1634 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1635 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1636 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1637 |
2482 | 1638 /** |
1639 * @def GET_MVDATA(_dmv_x, _dmv_y) | |
1640 * @brief Get MV differentials | |
1641 * @see MVDATA decoding from 8.3.5.2, p(1)20 | |
1642 * @param dmv_x Horizontal differential for decoded MV | |
1643 * @param dmv_y Vertical differential for decoded MV | |
1644 */ | |
2462 | 1645 #define GET_MVDATA(_dmv_x, _dmv_y) \ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1646 index = 1 + get_vlc2(gb, vc9_mv_diff_vlc[s->mv_table_index].table,\ |
2462 | 1647 VC9_MV_DIFF_VLC_BITS, 2); \ |
1648 if (index > 36) \ | |
1649 { \ | |
1650 mb_has_coeffs = 1; \ | |
1651 index -= 37; \ | |
1652 } \ | |
1653 else mb_has_coeffs = 0; \ | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1654 s->mb_intra = 0; \ |
2462 | 1655 if (!index) { _dmv_x = _dmv_y = 0; } \ |
1656 else if (index == 35) \ | |
1657 { \ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1658 _dmv_x = get_bits(gb, v->k_x); \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1659 _dmv_y = get_bits(gb, v->k_y); \ |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
1660 s->mb_intra = 1; \ |
2462 | 1661 } \ |
1662 else \ | |
1663 { \ | |
1664 index1 = index%6; \ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1665 if (s->mspel && index1 == 5) val = 1; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1666 else val = 0; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1667 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1668 sign = 0 - (val&1); \ |
1669 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ | |
1670 \ | |
1671 index1 = index/6; \ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1672 if (s->mspel && index1 == 5) val = 1; \ |
2462 | 1673 else val = 0; \ |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1674 val = get_bits(gb, size_table[index1] - val); \ |
2462 | 1675 sign = 0 - (val&1); \ |
1676 _dmv_y = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1677 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1678 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1679 /** Get predicted DC value |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1680 * prediction dir: left=0, top=1 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1681 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1682 static inline int vc9_pred_dc(MpegEncContext *s, int n, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1683 uint16_t **dc_val_ptr, int *dir_ptr) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1684 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1685 int a, b, c, wrap, pred, scale; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1686 int16_t *dc_val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1687 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1688 /* find prediction */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1689 if (n < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1690 scale = s->y_dc_scale; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1691 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1692 scale = s->c_dc_scale; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1693 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1694 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1695 wrap = s->block_wrap[n]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1696 dc_val= s->dc_val[0] + s->block_index[n]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1697 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1698 /* B C |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1699 * A X |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1700 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1701 a = dc_val[ - 1]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1702 b = dc_val[ - 1 - wrap]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1703 c = dc_val[ - wrap]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1704 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1705 if(s->first_slice_line && (n&2)==0) b=c=1024; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1706 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1707 /* XXX: the following solution consumes divisions, but it does not |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1708 necessitate to modify mpegvideo.c. The problem comes from the |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1709 fact they decided to store the quantized DC (which would lead |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1710 to problems if Q could vary !) */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1711 #if (defined(ARCH_X86) || defined(ARCH_X86_64)) && !defined PIC |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1712 asm volatile( |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1713 "movl %3, %%eax \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1714 "shrl $1, %%eax \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1715 "addl %%eax, %2 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1716 "addl %%eax, %1 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1717 "addl %0, %%eax \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1718 "mull %4 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1719 "movl %%edx, %0 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1720 "movl %1, %%eax \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1721 "mull %4 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1722 "movl %%edx, %1 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1723 "movl %2, %%eax \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1724 "mull %4 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1725 "movl %%edx, %2 \n\t" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1726 : "+b" (a), "+c" (b), "+D" (c) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1727 : "g" (scale), "S" (inverse[scale]) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1728 : "%eax", "%edx" |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1729 ); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1730 #else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1731 /* #elif defined (ARCH_ALPHA) */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1732 /* Divisions are extremely costly on Alpha; optimize the most |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1733 common case. But they are costly everywhere... |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1734 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1735 if (scale == 8) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1736 a = (a + (8 >> 1)) / 8; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1737 b = (b + (8 >> 1)) / 8; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1738 c = (c + (8 >> 1)) / 8; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1739 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1740 a = FASTDIV((a + (scale >> 1)), scale); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1741 b = FASTDIV((b + (scale >> 1)), scale); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1742 c = FASTDIV((c + (scale >> 1)), scale); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1743 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1744 #endif |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1745 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1746 if (abs(a - b) <= abs(b - c)) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1747 pred = c; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1748 *dir_ptr = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1749 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1750 pred = a; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1751 *dir_ptr = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1752 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1753 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1754 /* update predictor */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1755 *dc_val_ptr = &dc_val[0]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1756 return pred; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1757 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1758 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1759 /** Decode one block, inter or intra |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1760 * @param v The VC9 context |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1761 * @param block 8x8 DCT block |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1762 * @param n Block index in the current MB (<4=>luma) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1763 * @param coded If the block is coded |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1764 * @param MB quant, if decoded at the MB layer |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1765 * @see Inter TT: Table 21, p73 + p91-85 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1766 * @see Intra TT: Table 20, p72 + p(1)05-(1)07 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1767 * @todo TODO: Process the blocks |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1768 * @todo TODO: Use M$ MPEG-4 cbp prediction |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1769 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1770 int vc9_decode_block(VC9Context *v, DCTELEM block[64], int n, int coded, int mquant) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1771 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1772 GetBitContext *gb = &v->s.gb; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1773 MpegEncContext *s = &v->s; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1774 int ttblk; /* Transform Type per Block */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1775 int subblkpat; /* Sub-block Transform Type Pattern */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1776 int dc_pred_dir; /* Direction of the DC prediction used */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1777 int run_diff, i; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1778 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1779 if (s->mb_intra) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1780 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1781 int dcdiff; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1782 uint16_t *dc_val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1783 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1784 /* Get DC differential */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1785 if (n < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1786 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1787 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1788 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1789 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1790 if (dcdiff < 0){ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1791 av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n"); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1792 return -1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1793 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1794 if (dcdiff) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1795 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1796 if (dcdiff == 119 /* ESC index value */) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1797 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1798 /* TODO: Optimize */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1799 if (mquant == 1) dcdiff = get_bits(gb, 10); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1800 else if (mquant == 2) dcdiff = get_bits(gb, 9); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1801 else dcdiff = get_bits(gb, 8); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1802 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1803 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1804 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1805 if (mquant == 1) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1806 dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1807 else if (mquant == 2) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1808 dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1809 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1810 if (get_bits(gb, 1)) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1811 dcdiff = -dcdiff; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1812 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1813 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1814 /* Prediction */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1815 dcdiff += vc9_pred_dc(s, n, &dc_val, &dc_pred_dir); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1816 if (n < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1817 *dc_val = dcdiff * s->y_dc_scale; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1818 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1819 *dc_val = dcdiff * s->c_dc_scale; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1820 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1821 if (dcdiff < 0) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1822 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1823 av_log(s->avctx, AV_LOG_ERROR, "DC=%i<0\n", dcdiff); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1824 return -1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1825 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1826 block[0] = dcdiff; //XXX: Must be > 0 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1827 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1828 /* Skip ? */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1829 run_diff = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1830 i = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1831 if (!coded) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1832 goto not_coded; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1833 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1834 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1835 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1836 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1837 mquant = v->pq; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1838 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1839 /* Get TTBLK */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1840 if (v->ttmb < 8) /* per block */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1841 ttblk = get_vlc2(gb, vc9_ttblk_vlc[v->tt_index].table, VC9_TTBLK_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1842 else /* Per frame */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1843 ttblk = 0; //FIXME, depends on ttfrm |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1844 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1845 /* Get SUBBLKPAT */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1846 if (ttblk == v->ttblk4x4) /* 4x4 transform for that qp value */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1847 subblkpat = 1+get_vlc2(gb, vc9_subblkpat_vlc[v->tt_index].table, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1848 VC9_SUBBLKPAT_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1849 else /* All others: 8x8, 4x8, 8x4 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1850 subblkpat = decode012(gb); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1851 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1852 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1853 //TODO AC Decoding |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1854 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1855 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1856 not_coded: |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1857 if (s->mb_intra) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1858 mpeg4_pred_ac(s, block, n, dc_pred_dir); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1859 if (s->ac_pred) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1860 i = 63; /* XXX: not optimal */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1861 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1862 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1863 if(i>0) i=63; //FIXME/XXX optimize |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1864 s->block_last_index[n] = i; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1865 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1866 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1867 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1868 /** @} */ //End for group block |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1869 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1870 /***********************************************************************/ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1871 /** |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1872 * @defgroup std_mb VC9 Macroblock-level functions in Simple/Main Profiles |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1873 * @see 7.1.4, p91 and 8.1.1.7, p(1)04 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1874 * @todo TODO: Integrate to MpegEncContext facilities |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1875 * @{ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1876 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1877 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1878 static inline int vc9_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1879 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1880 int xy, wrap, pred, a, b, c; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1881 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1882 xy = s->block_index[n]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1883 wrap = s->b8_stride; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1884 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1885 /* B C |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1886 * A X |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1887 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1888 a = s->coded_block[xy - 1 ]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1889 b = s->coded_block[xy - 1 - wrap]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1890 c = s->coded_block[xy - wrap]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1891 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1892 if (b == c) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1893 pred = a; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1894 } else { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1895 pred = c; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1896 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1897 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1898 /* store value */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1899 *coded_block_ptr = &s->coded_block[xy]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1900 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1901 return pred; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1902 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1903 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1904 int vc9_decode_i_mb(VC9Context *v, DCTELEM block[6][64]) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1905 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1906 int i, cbp, val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1907 uint8_t *coded_val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1908 uint32_t * const mb_type_ptr= &v->s.current_picture.mb_type[ v->s.mb_x + v->s.mb_y*v->s.mb_stride ]; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1909 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1910 v->s.mb_intra = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1911 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1912 if (cbp < 0) return -1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1913 v->s.ac_pred = get_bits(&v->s.gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1914 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1915 for (i=0; i<6; i++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1916 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1917 val = ((cbp >> (5 - i)) & 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1918 if (i < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1919 int pred = vc9_coded_block_pred(&v->s, i, &coded_val); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1920 val = val ^ pred; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1921 *coded_val = val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1922 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1923 cbp |= val << (5 - i); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1924 if (vc9_decode_block(v, block[i], i, val, v->pq) < 0) //FIXME Should be mquant |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1925 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1926 av_log(v->s.avctx, AV_LOG_ERROR, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1927 "\nerror while decoding block: %d x %d (%d)\n", v->s.mb_x, v->s.mb_y, i); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1928 return -1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1929 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1930 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1931 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1932 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1933 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1934 int vc9_decode_p_mb(VC9Context *v, DCTELEM block[6][64]) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1935 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1936 MpegEncContext *s = &v->s; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1937 GetBitContext *gb = &s->gb; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1938 int i, mb_offset = s->mb_x + s->mb_y*s->mb_width; /* XXX: mb_stride */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1939 int cbp; /* cbp decoding stuff */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1940 int hybrid_pred; /* Prediction types */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1941 int mv_mode_bit = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1942 int mqdiff, mquant; /* MB quantization */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1943 int ttmb; /* MB Transform type */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1944 int status; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1945 uint8_t *coded_val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1946 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1947 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1948 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1949 int mb_has_coeffs = 1; /* last_flag */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1950 int dmv_x, dmv_y; /* Differential MV components */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1951 int index, index1; /* LUT indices */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1952 int val, sign; /* temp values */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1953 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1954 if (v->mv_type_mb_plane.is_raw) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1955 v->mv_type_mb_plane.data[mb_offset] = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1956 if (v->skip_mb_plane.is_raw) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1957 v->skip_mb_plane.data[mb_offset] = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1958 if (!mv_mode_bit) /* 1MV mode */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1959 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1960 if (!v->skip_mb_plane.data[mb_offset]) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1961 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1962 GET_MVDATA(dmv_x, dmv_y); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1963 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1964 /* hybrid mv pred, 8.3.5.3.4 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1965 if (v->mv_mode == MV_PMODE_1MV || |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1966 v->mv_mode == MV_PMODE_MIXED_MV) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1967 hybrid_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1968 if (s->mb_intra && !mb_has_coeffs) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1969 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1970 GET_MQUANT(); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1971 s->ac_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1972 /* XXX: how to handle cbp ? */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1973 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1974 else if (mb_has_coeffs) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1975 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1976 if (s->mb_intra) s->ac_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1977 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1978 GET_MQUANT(); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1979 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1980 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1981 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1982 mquant = v->pq; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1983 /* XXX: How to handle cbp ? */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1984 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1985 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1986 if (!v->ttmbf) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1987 ttmb = get_vlc2(gb, vc9_ttmb_vlc[v->tt_index].table, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1988 VC9_TTMB_VLC_BITS, 12); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1989 for (i=0; i<6; i++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1990 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1991 val = ((cbp >> (5 - i)) & 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1992 if (i < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1993 int pred = vc9_coded_block_pred(&v->s, i, &coded_val); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1994 val = val ^ pred; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1995 *coded_val = val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1996 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1997 vc9_decode_block(v, block[i], i, val, mquant); //FIXME |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1998 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
1999 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2000 else //Skipped |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2001 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2002 /* hybrid mv pred, 8.3.5.3.4 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2003 if (v->mv_mode == MV_PMODE_1MV || |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2004 v->mv_mode == MV_PMODE_MIXED_MV) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2005 hybrid_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2006 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2007 /* TODO: blah */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2008 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2009 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2010 } //1MV mode |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2011 else //4MV mode |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2012 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2013 if (!v->skip_mb_plane.data[mb_offset] /* unskipped MB */) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2014 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2015 /* Get CBPCY */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2016 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2017 for (i=0; i<6; i++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2018 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2019 val = ((cbp >> (5 - i)) & 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2020 if (i < 4) { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2021 int pred = vc9_coded_block_pred(&v->s, i, &coded_val); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2022 val = val ^ pred; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2023 *coded_val = val; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2024 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2025 if (i<4 && val) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2026 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2027 GET_MVDATA(dmv_x, dmv_y); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2028 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2029 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2030 hybrid_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2031 GET_MQUANT(); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2032 if (s->mb_intra /* One of the 4 blocks is intra */ && |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2033 index /* non-zero pred for that block */) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2034 s->ac_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2035 if (!v->ttmbf) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2036 ttmb = get_vlc2(gb, vc9_ttmb_vlc[v->tt_index].table, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2037 VC9_TTMB_VLC_BITS, 12); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2038 status = vc9_decode_block(v, block[i], i, val, mquant); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2039 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2040 return status; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2041 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2042 else //Skipped MB |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2043 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2044 for (i=0; i<4; i++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2045 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2046 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2047 hybrid_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2048 vc9_decode_block(v, block[i], i, 0 /*cbp[i]*/, mquant); //FIXME |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2049 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2050 /* TODO: blah */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2051 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2052 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2053 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2054 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2055 /* Should never happen */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2056 return -1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2057 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2058 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2059 int vc9_decode_b_mb(VC9Context *v, DCTELEM block[6][64]) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2060 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2061 int i; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2062 //Decode CBP |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2063 for (i=0; i<6; i++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2064 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2065 vc9_decode_block(v, block[i], i, 0 /*cbp[i]*/, v->pq /*Should be mquant*/); //FIXME |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2066 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2067 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2068 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2069 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2070 static int standard_decode_mbs(VC9Context *v) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2071 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2072 GetBitContext *gb = &v->s.gb; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2073 MpegEncContext *s = &v->s; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2074 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2075 /* Set transform type info depending on pq */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2076 if (v->pq < 5) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2077 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2078 v->tt_index = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2079 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2080 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2081 else if (v->pq < 13) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2082 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2083 v->tt_index = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2084 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2085 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2086 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2087 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2088 v->tt_index = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2089 v->ttblk4x4 = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2090 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2091 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2092 if (s->pict_type != I_TYPE) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2093 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2094 /* Select proper long MV range */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2095 switch (v->mvrange) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2096 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2097 case 1: v->k_x = 10; v->k_y = 9; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2098 case 2: v->k_x = 12; v->k_y = 10; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2099 case 3: v->k_x = 13; v->k_y = 11; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2100 default: /*case 0 too */ v->k_x = 9; v->k_y = 8; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2101 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2102 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2103 s->mspel = v->mv_mode & 1; //MV_PMODE is HPEL |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2104 v->k_x -= s->mspel; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2105 v->k_y -= s->mspel; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2106 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2107 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2108 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2109 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2110 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2111 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2112 //FIXME Get proper MB DCTELEM |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2113 //TODO Move out of the loop |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2114 switch (s->pict_type) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2115 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2116 case I_TYPE: vc9_decode_i_mb(v, NULL); break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2117 case P_TYPE: vc9_decode_i_mb(v, NULL); break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2118 case BI_TYPE: |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2119 case B_TYPE: vc9_decode_i_mb(v, NULL); break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2120 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2121 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2122 //Add a check for overconsumption ? |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2123 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2124 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2125 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2126 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2127 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2128 /** |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2129 * @def GET_CBPCY(table, bits) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2130 * @brief Get the Coded Block Pattern for luma and chroma |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2131 * @param table VLC table to use (get_vlc2 second parameter) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2132 * @param bits Average bitlength (third parameter to get_vlc2) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2133 * @see 8.1.1.5, p(1)02-(1)03 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2134 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2135 #define GET_CBPCY(table, bits) \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2136 predicted_cbpcy = get_vlc2(gb, table, bits, 2); \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2137 cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2138 ? previous_cbpcy[1] : p_cbpcy[+2]; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2139 cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01); \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2140 cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3]; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2141 cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01); \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2142 cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2143 ? previous_cbpcy[3] : cbpcy[0]; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2144 cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01); \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2145 cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1]; \ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2146 cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2147 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2148 /** Decode all MBs for an I frame in Simple/Main profile |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2149 * @see 8.1, p100 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2150 * @todo TODO: Process the blocks |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2151 * @todo TODO: Use M$ MPEG-4 cbp prediction |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2152 */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2153 static int standard_decode_i_mbs(VC9Context *v) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2154 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2155 GetBitContext *gb = &v->s.gb; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2156 MpegEncContext *s = &v->s; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2157 int mb_offset = 0; /* MB/Block Position info */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2158 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2159 *p_cbpcy /* Pointer to skip some math */; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2160 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2161 /* Reset CBPCY predictors */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2162 memset(v->previous_line_cbpcy, 0, s->mb_stride<<2); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2163 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2164 /* Select ttmb table depending on pq */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2165 if (v->pq < 5) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2166 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2167 v->tt_index = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2168 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2169 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2170 else if (v->pq < 13) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2171 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2172 v->tt_index = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2173 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2174 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2175 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2176 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2177 v->tt_index = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2178 v->ttblk4x4 = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2179 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2180 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2181 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2182 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2183 /* Init CBPCY for line */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2184 *((uint32_t*)previous_cbpcy) = 0x00000000; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2185 p_cbpcy = v->previous_line_cbpcy+4; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2186 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2187 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2188 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2189 /* Get CBPCY */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2190 GET_CBPCY(ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2191 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2192 s->ac_pred = get_bits(gb, 1); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2193 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2194 /* TODO: Decode blocks from that mb wrt cbpcy */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2195 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2196 /* Update for next block */ |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2197 #if TRACE > 2 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2198 av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i," |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2199 " cbpcy=%i%i%i%i\n", mb_offset, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2200 p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3], |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2201 previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3], |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2202 cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2203 #endif |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2204 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2205 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2206 mb_offset++; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2207 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2208 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2209 return 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2210 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2211 |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2212 |
2482 | 2213 /** Decode all MBs for an P frame in Simple/Main profile |
2214 * @see 8.1, p(1)15 | |
2215 * @todo TODO: Process the blocks | |
2216 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
2217 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2218 static int decode_p_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2219 { |
2474 | 2220 MpegEncContext *s = &v->s; |
2221 GetBitContext *gb = &v->s.gb; | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2222 int mb_offset = 0, i; /* MB/Block Position info */ |
2462 | 2223 uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy, |
2224 *p_cbpcy /* Pointer to skip some math */; | |
2474 | 2225 int hybrid_pred; /* Prediction types */ |
2462 | 2226 int mv_mode_bit = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2227 int mqdiff, mquant; /* MB quantization */ |
2462 | 2228 int ttmb; /* MB Transform type */ |
2229 | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2230 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2231 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2232 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 2233 int dmv_x, dmv_y; /* Differential MV components */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2234 int index, index1; /* LUT indices */ |
2462 | 2235 int val, sign; /* MVDATA temp values */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2236 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2237 /* Select ttmb table depending on pq */ |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2238 if (v->pq < 5) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2239 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2240 v->tt_index = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2241 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2242 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2243 else if (v->pq < 13) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2244 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2245 v->tt_index = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2246 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2247 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2248 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2249 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2250 v->tt_index = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2251 v->ttblk4x4 = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2252 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2253 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2254 /* Select proper long MV range */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2255 switch (v->mvrange) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2256 { |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2257 case 1: v->k_x = 10; v->k_y = 9; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2258 case 2: v->k_x = 12; v->k_y = 10; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2259 case 3: v->k_x = 13; v->k_y = 11; break; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2260 default: /*case 0 too */ v->k_x = 9; v->k_y = 8; break; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2261 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2262 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2263 s->mspel = v->mv_mode & 1; //MV_PMODE is HPEL |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2264 v->k_x -= s->mspel; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2265 v->k_y -= s->mspel; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2266 |
2462 | 2267 /* Reset CBPCY predictors */ |
2474 | 2268 memset(v->previous_line_cbpcy, 0, s->mb_stride<<2); |
2462 | 2269 |
2474 | 2270 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2271 { |
2462 | 2272 /* Init CBPCY for line */ |
2273 *((uint32_t*)previous_cbpcy) = 0x00000000; | |
2274 p_cbpcy = v->previous_line_cbpcy+4; | |
2275 | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2276 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2277 { |
2462 | 2278 if (v->mv_type_mb_plane.is_raw) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2279 v->mv_type_mb_plane.data[mb_offset] = get_bits(gb, 1); |
2462 | 2280 if (v->skip_mb_plane.is_raw) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2281 v->skip_mb_plane.data[mb_offset] = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2282 if (!mv_mode_bit) /* 1MV mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2283 { |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2284 if (!v->skip_mb_plane.data[mb_offset]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2285 { |
2462 | 2286 GET_MVDATA(dmv_x, dmv_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2287 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2288 /* hybrid mv pred, 8.3.5.3.4 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2289 if (v->mv_mode == MV_PMODE_1MV || |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2290 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 2291 hybrid_pred = get_bits(gb, 1); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2292 if (s->mb_intra && !mb_has_coeffs) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2293 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2294 GET_MQUANT(); |
2474 | 2295 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2296 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2297 else if (mb_has_coeffs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2298 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2299 if (s->mb_intra) s->ac_pred = get_bits(gb, 1); |
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2300 predicted_cbpcy = get_vlc2(gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2); |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2301 GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2302 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2303 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2304 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2305 if (!v->ttmbf) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2306 ttmb = get_vlc2(gb, vc9_ttmb_vlc[v->tt_index].table, |
2462 | 2307 VC9_TTMB_VLC_BITS, 12); |
2308 /* TODO: decode blocks from that mb wrt cbpcy */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2309 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2310 else //Skipped |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2311 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2312 /* hybrid mv pred, 8.3.5.3.4 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2313 if (v->mv_mode == MV_PMODE_1MV || |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2314 v->mv_mode == MV_PMODE_MIXED_MV) |
2474 | 2315 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2316 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2317 } //1MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2318 else //4MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2319 { |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2320 if (!v->skip_mb_plane.data[mb_offset] /* unskipped MB */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2321 { |
2462 | 2322 /* Get CBPCY */ |
2323 GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2324 for (i=0; i<4; i++) //For all 4 Y blocks |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2325 { |
2462 | 2326 if (cbpcy[i] /* cbpcy set for this block */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2327 { |
2462 | 2328 GET_MVDATA(dmv_x, dmv_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2329 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2330 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 2331 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2332 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2333 if (s->mb_intra /* One of the 4 blocks is intra */ && |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2334 index /* non-zero pred for that block */) |
2474 | 2335 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2336 if (!v->ttmbf) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2337 ttmb = get_vlc2(gb, vc9_ttmb_vlc[v->tt_index].table, |
2462 | 2338 VC9_TTMB_VLC_BITS, 12); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2339 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2340 /* TODO: Process blocks wrt cbpcy */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2341 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2342 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2343 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2344 else //Skipped MB |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2345 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2346 for (i=0; i<4; i++) //All 4 Y blocks |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2347 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2348 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
2474 | 2349 hybrid_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2350 |
2462 | 2351 /* TODO: do something */ |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2352 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2353 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2354 } |
2462 | 2355 |
2356 /* Update for next block */ | |
2357 #if TRACE > 2 | |
2474 | 2358 av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i," |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2359 " cbpcy=%i%i%i%i\n", mb_offset, |
2462 | 2360 p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3], |
2361 previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3], | |
2362 cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]); | |
2363 #endif | |
2364 *((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy); | |
2365 *((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy); | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2366 mb_offset++; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2367 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2368 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2369 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2370 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2371 |
2482 | 2372 /** Decode all MBs for an P frame in Simple/Main profile |
2373 * @todo TODO: Process the blocks | |
2374 * @todo TODO: Use M$ MPEG-4 cbp prediction | |
2375 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2376 static int decode_b_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2377 { |
2474 | 2378 MpegEncContext *s = &v->s; |
2379 GetBitContext *gb = &v->s.gb; | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2380 int mb_offset = 0, i /* MB / B postion information */; |
2462 | 2381 int b_mv_type = BMV_TYPE_BACKWARD; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2382 int mquant, mqdiff; /* MB quant stuff */ |
2462 | 2383 int ttmb; /* MacroBlock transform type */ |
2384 | |
2385 static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, | |
2386 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; | |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2387 int mb_has_coeffs = 1; /* last_flag */ |
2462 | 2388 int dmv1_x, dmv1_y, dmv2_x, dmv2_y; /* Differential MV components */ |
2389 int k_x, k_y; /* Long MV fixed bitlength */ | |
2390 int hpel_flag; /* Some MB properties */ | |
2391 int index, index1; /* LUT indices */ | |
2392 int val, sign; /* MVDATA temp values */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2393 |
2462 | 2394 /* Select proper long MV range */ |
2395 switch (v->mvrange) | |
2396 { | |
2397 case 1: k_x = 10; k_y = 9; break; | |
2398 case 2: k_x = 12; k_y = 10; break; | |
2399 case 3: k_x = 13; k_y = 11; break; | |
2400 default: /*case 0 too */ k_x = 9; k_y = 8; break; | |
2401 } | |
2402 hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL | |
2403 k_x -= hpel_flag; | |
2404 k_y -= hpel_flag; | |
2405 | |
2406 /* Select ttmb table depending on pq */ | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2407 if (v->pq < 5) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2408 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2409 v->tt_index = 0; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2410 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2411 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2412 else if (v->pq < 13) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2413 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2414 v->tt_index = 1; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2415 v->ttblk4x4 = 3; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2416 } |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2417 else |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2418 { |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2419 v->tt_index = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2420 v->ttblk4x4 = 2; |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2421 } |
2462 | 2422 |
2474 | 2423 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2424 { |
2474 | 2425 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2426 { |
2462 | 2427 if (v->direct_mb_plane.is_raw) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2428 v->direct_mb_plane.data[mb_offset] = get_bits(gb, 1); |
2462 | 2429 if (v->skip_mb_plane.is_raw) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2430 v->skip_mb_plane.data[mb_offset] = get_bits(gb, 1); |
2462 | 2431 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2432 if (!v->direct_mb_plane.data[mb_offset]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2433 { |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2434 if (v->skip_mb_plane.data[mb_offset]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2435 { |
2474 | 2436 b_mv_type = decode012(gb); |
2462 | 2437 if (v->bfraction > 420 /*1/2*/ && |
2438 b_mv_type < 3) b_mv_type = 1-b_mv_type; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2439 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2440 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2441 { |
2462 | 2442 GET_MVDATA(dmv1_x, dmv1_y); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2443 if (!s->mb_intra /* b_mv1 tells not intra */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2444 { |
2474 | 2445 b_mv_type = decode012(gb); |
2462 | 2446 if (v->bfraction > 420 /*1/2*/ && |
2447 b_mv_type < 3) b_mv_type = 1-b_mv_type; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2448 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2449 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2450 } |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2451 if (!v->skip_mb_plane.data[mb_offset]) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2452 { |
2462 | 2453 if (mb_has_coeffs /* BMV1 == "last" */) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2454 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2455 GET_MQUANT(); |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2456 if (s->mb_intra /* intra mb */) |
2474 | 2457 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2458 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2459 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2460 { |
2462 | 2461 /* if bmv1 tells MVs are interpolated */ |
2462 if (b_mv_type == BMV_TYPE_INTERPOLATED) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2463 { |
2462 | 2464 GET_MVDATA(dmv2_x, dmv2_y); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2465 } |
2462 | 2466 /* GET_MVDATA has reset some stuff */ |
2467 if (mb_has_coeffs /* b_mv2 == "last" */) | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2468 { |
2475
db05cb59c6fc
- add another way to decode norm6 VLC; modify VLC_NORM6_METH0D define in
michael
parents:
2474
diff
changeset
|
2469 if (s->mb_intra /* intra_mb */) |
2474 | 2470 s->ac_pred = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2471 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2472 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2473 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2474 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2475 //End1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2476 if (v->ttmbf) |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2477 ttmb = get_vlc2(gb, vc9_ttmb_vlc[v->tt_index].table, |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2478 VC9_TTMB_VLC_BITS, 12); |
2462 | 2479 |
2480 //End2 | |
2481 for (i=0; i<6; i++) | |
2482 { | |
2483 /* FIXME: process the block */ | |
2484 } | |
2485 | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2486 mb_offset++; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2487 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2488 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2489 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2490 } |
2482 | 2491 /** @} */ //End for group std_mb |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2492 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2493 #if HAS_ADVANCED_PROFILE |
2482 | 2494 /***********************************************************************/ |
2495 /** | |
2496 * @defgroup adv_mb VC9 Macroblock-level functions in Advanced Profile | |
2497 * @todo TODO: Integrate to MpegEncContext facilities | |
2498 * @todo TODO: Code P, B and BI | |
2499 * @{ | |
2500 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2501 static int advanced_decode_i_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2502 { |
2474 | 2503 MpegEncContext *s = &v->s; |
2504 GetBitContext *gb = &v->s.gb; | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2505 int mqdiff, mquant, mb_offset = 0, over_flags_mb = 0; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2506 |
2474 | 2507 for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2508 { |
2474 | 2509 for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2510 { |
2474 | 2511 if (v->ac_pred_plane.is_raw) |
2512 s->ac_pred = get_bits(gb, 1); | |
2513 else | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2514 s->ac_pred = v->ac_pred_plane.data[mb_offset]; |
2462 | 2515 if (v->condover == 3 && v->over_flags_plane.is_raw) |
2474 | 2516 over_flags_mb = get_bits(gb, 1); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2517 GET_MQUANT(); |
2462 | 2518 |
2519 /* TODO: lots */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2520 } |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2521 mb_offset++; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2522 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2523 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2524 } |
2482 | 2525 /** @} */ //End for group adv_mb |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2526 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2527 |
2482 | 2528 /** Initialize a VC9/WMV3 decoder |
2529 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2530 * @todo TODO: Decypher remaining bits in extra_data | |
2531 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2532 static int vc9_decode_init(AVCodecContext *avctx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2533 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2534 VC9Context *v = avctx->priv_data; |
2474 | 2535 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2536 GetBitContext gb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2537 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2538 if (!avctx->extradata_size || !avctx->extradata) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2539 avctx->pix_fmt = PIX_FMT_YUV420P; |
2474 | 2540 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2541 |
2474 | 2542 if(ff_h263_decode_init(avctx) < 0) |
2543 return -1; | |
2544 if (vc9_init_common(v) < 0) return -1; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2545 |
2462 | 2546 avctx->coded_width = avctx->width; |
2547 avctx->coded_height = avctx->height; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2548 if (avctx->codec_id == CODEC_ID_WMV3) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2549 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2550 int count = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2551 |
2474 | 2552 // looks like WMV3 has a sequence header stored in the extradata |
2553 // advanced sequence header may be before the first frame | |
2554 // the last byte of the extradata is a version number, 1 for the | |
2555 // samples we can decode | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2556 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2557 init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8); |
2474 | 2558 |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2559 if (decode_sequence_header(avctx, &gb) < 0) |
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2560 return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2561 |
2474 | 2562 count = avctx->extradata_size*8 - get_bits_count(&gb); |
2563 if (count>0) | |
2564 { | |
2565 av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", | |
2566 count, get_bits(&gb, count)); | |
2567 } | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2568 else if (count < 0) |
2474 | 2569 { |
2570 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); | |
2571 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2572 } |
2474 | 2573 avctx->has_b_frames= !!(avctx->max_b_frames); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2574 |
2474 | 2575 s->mb_width = (avctx->coded_width+15)>>4; |
2576 s->mb_height = (avctx->coded_height+15)>>4; | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2577 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2578 /* Allocate mb bitplanes */ |
2474 | 2579 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2580 return -1; |
2474 | 2581 if (alloc_bitplane(&v->mv_type_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2582 return -1; |
2474 | 2583 if (alloc_bitplane(&v->skip_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2584 return -1; |
2474 | 2585 if (alloc_bitplane(&v->direct_mb_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2586 return -1; |
2587 | |
2588 /* For predictors */ | |
2474 | 2589 v->previous_line_cbpcy = (uint8_t *)av_malloc(s->mb_stride*4); |
2462 | 2590 if (!v->previous_line_cbpcy) return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2591 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2592 #if HAS_ADVANCED_PROFILE |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2593 if (v->profile == PROFILE_ADVANCED) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2594 { |
2474 | 2595 if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2596 return -1; |
2474 | 2597 if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) |
2462 | 2598 return -1; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2599 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2600 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2601 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2602 return 0; |
2474 | 2603 } |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2604 |
2482 | 2605 /** Decode a VC9/WMV3 frame |
2606 * @todo TODO: Handle VC-9 IDUs (Transport level?) | |
2607 * @warning Initial try at using MpegEncContext stuff | |
2608 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2609 static int vc9_decode_frame(AVCodecContext *avctx, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2610 void *data, int *data_size, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2611 uint8_t *buf, int buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2612 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2613 VC9Context *v = avctx->priv_data; |
2474 | 2614 MpegEncContext *s = &v->s; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2615 int ret = FRAME_SKIPED, len, start_code; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2616 AVFrame *pict = data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2617 uint8_t *tmp_buf; |
2474 | 2618 v->s.avctx = avctx; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2619 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2620 //buf_size = 0 -> last frame |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2621 if (!buf_size) return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2622 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2623 len = avpicture_get_size(avctx->pix_fmt, avctx->width, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2624 avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2625 tmp_buf = (uint8_t *)av_mallocz(len); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2626 avpicture_fill((AVPicture *)pict, tmp_buf, avctx->pix_fmt, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2627 avctx->width, avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2628 |
2474 | 2629 if (avctx->codec_id == CODEC_ID_VC9) |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2630 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2631 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2632 // search for IDU's |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2633 // FIXME |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2634 uint32_t scp = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2635 int scs = 0, i = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2636 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2637 while (i < buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2638 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2639 for (; i < buf_size && scp != 0x000001; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2640 scp = ((scp<<8)|buf[i])&0xffffff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2641 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2642 if (scp != 0x000001) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2643 break; // eof ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2644 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2645 scs = buf[i++]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2646 |
2474 | 2647 init_get_bits(gb, buf+i, (buf_size-i)*8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2648 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2649 switch(scs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2650 { |
2462 | 2651 case 0x0A: //Sequence End Code |
2652 return 0; | |
2653 case 0x0B: //Slice Start Code | |
2654 av_log(avctx, AV_LOG_ERROR, "Slice coding not supported\n"); | |
2655 return -1; | |
2656 case 0x0C: //Field start code | |
2657 av_log(avctx, AV_LOG_ERROR, "Interlaced coding not supported\n"); | |
2658 return -1; | |
2659 case 0x0D: //Frame start code | |
2660 break; | |
2661 case 0x0E: //Entry point Start Code | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2662 if (v->profile < PROFILE_ADVANCED) |
2462 | 2663 av_log(avctx, AV_LOG_ERROR, |
2664 "Found an entry point in profile %i\n", v->profile); | |
2474 | 2665 advanced_entry_point_process(avctx, gb); |
2462 | 2666 break; |
2667 case 0x0F: //Sequence header Start Code | |
2474 | 2668 decode_sequence_header(avctx, gb); |
2462 | 2669 break; |
2670 default: | |
2671 av_log(avctx, AV_LOG_ERROR, | |
2672 "Unsupported IDU suffix %lX\n", scs); | |
2673 } | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2674 |
2474 | 2675 i += get_bits_count(gb)*8; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2676 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2677 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2678 av_abort(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2679 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2680 } |
2474 | 2681 else |
2682 init_get_bits(&v->s.gb, buf, buf_size*8); | |
2683 | |
2684 s->flags= avctx->flags; | |
2685 s->flags2= avctx->flags2; | |
2686 | |
2687 /* no supplementary picture */ | |
2688 if (buf_size == 0) { | |
2689 /* special case for last picture */ | |
2690 if (s->low_delay==0 && s->next_picture_ptr) { | |
2691 *pict= *(AVFrame*)s->next_picture_ptr; | |
2692 s->next_picture_ptr= NULL; | |
2693 | |
2694 *data_size = sizeof(AVFrame); | |
2695 } | |
2696 | |
2697 return 0; | |
2698 } | |
2699 | |
2700 //No IDU - we mimic ff_h263_decode_frame | |
2701 s->bitstream_buffer_size=0; | |
2702 | |
2703 if (!s->context_initialized) { | |
2704 if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix | |
2705 return -1; | |
2706 } | |
2707 | |
2708 //we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there | |
2709 if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ | |
2710 s->current_picture_ptr= &s->picture[ff_find_unused_picture(s, 0)]; | |
2711 } | |
2712 #if HAS_ADVANCED_PROFILE | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2713 if (v->profile == PROFILE_ADVANCED) |
2474 | 2714 ret= advanced_decode_picture_primary_header(v); |
2715 else | |
2716 #endif | |
2717 ret= standard_decode_picture_primary_header(v); | |
2718 if (ret == FRAME_SKIPED) return buf_size; | |
2719 /* skip if the header was thrashed */ | |
2720 if (ret < 0){ | |
2721 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n"); | |
2722 return -1; | |
2723 } | |
2724 | |
2725 //No bug workaround yet, no DCT conformance | |
2726 | |
2727 //WMV9 does have resized images | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2728 if (v->profile < PROFILE_ADVANCED && v->multires){ |
2474 | 2729 //Parse context stuff in here, don't know how appliable it is |
2730 } | |
2731 //Not sure about context initialization | |
2732 | |
2733 // for hurry_up==5 | |
2734 s->current_picture.pict_type= s->pict_type; | |
2735 s->current_picture.key_frame= s->pict_type == I_TYPE; | |
2736 | |
2737 /* skip b frames if we dont have reference frames */ | |
2738 if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)) | |
2739 return buf_size; //FIXME simulating all buffer consumed | |
2740 /* skip b frames if we are in a hurry */ | |
2741 if(avctx->hurry_up && s->pict_type==B_TYPE) | |
2742 return buf_size; //FIXME simulating all buffer consumed | |
2743 /* skip everything if we are in a hurry>=5 */ | |
2744 if(avctx->hurry_up>=5) | |
2745 return buf_size; //FIXME simulating all buffer consumed | |
2746 | |
2747 if(s->next_p_frame_damaged){ | |
2748 if(s->pict_type==B_TYPE) | |
2749 return buf_size; //FIXME simulating all buffer consumed | |
2750 else | |
2751 s->next_p_frame_damaged=0; | |
2752 } | |
2753 | |
2754 if(MPV_frame_start(s, avctx) < 0) | |
2755 return -1; | |
2756 | |
2757 ff_er_frame_start(s); | |
2758 | |
2759 //wmv9 may or may not have skip bits | |
2760 #if HAS_ADVANCED_PROFILE | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2761 if (v->profile == PROFILE_ADVANCED) |
2474 | 2762 ret= advanced_decode_picture_secondary_header(v); |
2763 else | |
2764 #endif | |
2765 ret = standard_decode_picture_secondary_header(v); | |
2766 if (ret<0) return FRAME_SKIPED; //FIXME Non fatal for now | |
2767 | |
2768 //We consider the image coded in only one slice | |
2769 #if HAS_ADVANCED_PROFILE | |
2497
69adfbbdcdeb
- samples from mplayer ftp in the "adv" profile seem to have profile=2,
michael
parents:
2483
diff
changeset
|
2770 if (v->profile == PROFILE_ADVANCED) |
2474 | 2771 { |
2772 switch(s->pict_type) | |
2773 { | |
2774 case I_TYPE: ret = advanced_decode_i_mbs(v); break; | |
2775 case P_TYPE: ret = decode_p_mbs(v); break; | |
2776 case B_TYPE: | |
2777 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2778 default: ret = FRAME_SKIPED; | |
2779 } | |
2780 if (ret == FRAME_SKIPED) return buf_size; //We ignore for now failures | |
2781 } | |
2782 else | |
2783 #endif | |
2784 { | |
2785 switch(s->pict_type) | |
2786 { | |
2787 case I_TYPE: ret = standard_decode_i_mbs(v); break; | |
2788 case P_TYPE: ret = decode_p_mbs(v); break; | |
2789 case B_TYPE: | |
2790 case BI_TYPE: ret = decode_b_mbs(v); break; | |
2791 default: ret = FRAME_SKIPED; | |
2792 } | |
2793 if (ret == FRAME_SKIPED) return buf_size; | |
2794 } | |
2795 | |
2796 ff_er_frame_end(s); | |
2797 | |
2798 MPV_frame_end(s); | |
2799 | |
2800 assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); | |
2801 assert(s->current_picture.pict_type == s->pict_type); | |
2802 if(s->pict_type==B_TYPE || s->low_delay){ | |
2803 *pict= *(AVFrame*)&s->current_picture; | |
2804 ff_print_debug_info(s, pict); | |
2805 } else { | |
2806 *pict= *(AVFrame*)&s->last_picture; | |
2807 if(pict) | |
2808 ff_print_debug_info(s, pict); | |
2809 } | |
2810 | |
2811 /* Return the Picture timestamp as the frame number */ | |
2812 /* we substract 1 because it is added on utils.c */ | |
2813 avctx->frame_number = s->picture_number - 1; | |
2814 | |
2815 /* dont output the last pic after seeking */ | |
2816 if(s->last_picture_ptr || s->low_delay) | |
2817 *data_size = sizeof(AVFrame); | |
2818 | |
2462 | 2819 av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n", |
2474 | 2820 get_bits_count(&s->gb), buf_size*8); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2821 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2822 /* Fake consumption of all data */ |
2462 | 2823 *data_size = len; |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2824 return buf_size; //Number of bytes consumed |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2825 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2826 |
2482 | 2827 /** Close a VC9/WMV3 decoder |
2828 * @warning Initial try at using MpegEncContext stuff | |
2829 */ | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2830 static int vc9_decode_end(AVCodecContext *avctx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2831 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2832 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2833 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2834 #if HAS_ADVANCED_PROFILE |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2835 av_freep(&v->hrd_rate); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
2836 av_freep(&v->hrd_buffer); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2837 #endif |
2474 | 2838 MPV_common_end(&v->s); |
2839 free_bitplane(&v->mv_type_mb_plane); | |
2840 free_bitplane(&v->skip_mb_plane); | |
2841 free_bitplane(&v->direct_mb_plane); | |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2842 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2843 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2844 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2845 AVCodec vc9_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2846 "vc9", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2847 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2848 CODEC_ID_VC9, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2849 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2850 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2851 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2852 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2853 vc9_decode_frame, |
2453 | 2854 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2855 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2856 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2857 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2858 AVCodec wmv3_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2859 "wmv3", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2860 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2861 CODEC_ID_WMV3, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2862 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2863 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2864 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2865 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2866 vc9_decode_frame, |
2453 | 2867 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2868 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
2869 }; |