Mercurial > libavcodec.hg
annotate vc9.c @ 2458:915094e3da5d libavcodec
dont use several 100 mb memory for a tiny 120 element table
remove redundant code related to av_free()
typo fix
author | michael |
---|---|
date | Sun, 23 Jan 2005 22:54:51 +0000 |
parents | f67b63ed036d |
children | 7a875ef7597b |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
5 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
6 * 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
|
7 * 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
|
8 * 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
|
9 * 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
|
10 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * 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
|
15 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
16 * 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
|
17 * 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
|
18 * 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
|
19 * |
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 * @file vc9.c |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
24 * VC-9 and WMV3 decoder |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
25 * |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
26 * TODO: Norm-6 bitplane imode, most AP stuff, optimize, all of MB layer :) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
27 * TODO: use MPV_ !! |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
28 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
29 #include "common.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
30 #include "dsputil.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
31 #include "avcodec.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
32 #include "mpegvideo.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
33 #include "vc9data.h" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
34 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
35 /* Some inhibiting stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
36 #define HAS_ADVANCED_PROFILE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
37 #define TRACE 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
38 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
39 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
40 # 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
|
41 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
|
42 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
|
43 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
|
44 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
45 av_log(v->avctx, AV_LOG_ERROR, "Error for " # vlc " (%i)\n", i); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
46 return -1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
47 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
48 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
49 # 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
|
50 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
|
51 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
|
52 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
|
53 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
54 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
55 #define PROFILE_SIMPLE 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
56 #define PROFILE_MAIN 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
57 #define PROFILE_ADVANCED 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
58 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
59 #define QUANT_FRAME_IMPLICIT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
60 #define QUANT_FRAME_EXPLICIT 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
61 #define QUANT_NON_UNIFORM 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
62 #define QUANT_UNIFORM 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
63 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
64 /* Where quant can be changed */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
65 #define DQPROFILE_FOUR_EDGES 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
66 #define DQPROFILE_DOUBLE_EDGES 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
67 #define DQPROFILE_SINGLE_EDGE 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
68 #define DQPROFILE_ALL_MBS 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
69 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
70 /* Which edge is quantized with ALTPQUANT */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
71 #define DQSINGLE_BEDGE_LEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
72 #define DQSINGLE_BEDGE_TOP 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
73 #define DQSINGLE_BEDGE_RIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
74 #define DQSINGLE_BEDGE_BOTTOM 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
75 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
76 /* Which pair of edges is quantized with ALTPQUANT */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
77 #define DQDOUBLE_BEDGE_TOPLEFT 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
78 #define DQDOUBLE_BEDGE_TOPRIGHT 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
79 #define DQDOUBLE_BEDGE_BOTTOMRIGHT 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
80 #define DQDOUBLE_BEDGE_BOTTOMLEFT 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
81 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
82 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
83 /* Start Codes */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
84 #define SEQ_SC 0x00000010F /* Sequence Start Code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
85 #define SEQ_EC 0x00000000A /* Sequence End code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
86 #define SEQ_HDR /* Sequence Header */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
87 #define ENTRY_SC 0x00000010E /* Entry Point Start Code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
88 #define ENTRY_HDR /* Entry Point Header */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
89 #define FRM_SC 0x00000010D /* Frame Start Code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
90 #define FRM_DAT /* Frame Data (includes a Frame Header) */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
91 #define FLD_SC 0x00000010C /* Field Start Code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
92 #define FLD1_DAT /* Field 1 Data (includes a Frame Header) */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
93 #define FLD2_DAT /* Field 2 Data (includes a Field Header) */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
94 #define SLC_SC 0x00000010B /* Slice Start Code */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
95 #define SLC_HDR /* Slice Header */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
96 #define SLC_DAT /* Slice Data (FrH or FiH possible) */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
97 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
98 /* MV P modes */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
99 #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
|
100 #define MV_PMODE_1MV 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
101 #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
|
102 #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
|
103 #define MV_PMODE_INTENSITY_COMP 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
104 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
105 /* MV P mode - the 5th element is only used for mode 1 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
106 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
|
107 { 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
|
108 { 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
|
109 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
110 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
111 /* One more frame type */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
112 #define BI_TYPE 7 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
113 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
114 /* FIXME Worse than ugly */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
115 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
|
116 fps_dr[2] = { 1000, 1001 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
117 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
|
118 { /* Implicit quantizer */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
119 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
|
120 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
|
121 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
122 { /* Explicit quantizer, pquantizer uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
123 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
|
124 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
|
125 }, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
126 { /* Explicit quantizer, pquantizer non-uniform */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
127 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
|
128 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
|
129 } |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
132 // FIXME move this into the context |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
133 #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
|
134 static VLC vc9_bfraction_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
135 #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
|
136 static VLC vc9_imode_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
137 #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
|
138 static VLC vc9_norm2_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
139 /* Could be optimized, one table only needs 8 bits */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
140 #define VC9_TTMB_VLC_BITS 12 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
141 static VLC vc9_ttmb_vlc[3]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
142 #define VC9_MV_DIFF_VLC_BITS 15 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
143 static VLC vc9_mv_diff_vlc[4]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
144 #define VC9_CBPCY_I_VLC_BITS 13 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
145 static VLC vc9_cbpcy_i_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
146 #define VC9_CBPCY_P_VLC_BITS 14 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
147 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
|
148 #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
|
149 static VLC vc9_4mv_block_pattern_vlc[4]; |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
150 #define VC9_LUMA_DC_VLC_BITS 9 |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
151 static VLC vc9_luma_dc_vlc[2]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
152 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
153 typedef struct VC9Context{ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
154 /* No MpegEnc context, might be good to use it */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
155 GetBitContext gb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
156 AVCodecContext *avctx; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
157 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
158 /***************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
159 /* Sequence Header */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
160 /***************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
161 /* Simple/Main Profile */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
162 int res_sm; //reserved, 2b |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
163 int res_x8; //reserved |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
164 int multires; //frame-level RESPIC syntax element present |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
165 int res_fasttx; //always 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
166 int res_transtab; //always 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
167 int syncmarker; //Sync markers presents |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
168 int rangered; //RANGEREDFRM (range reduction) syntax element present |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
169 int res_rtm_flag; //reserved, set to 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
170 int reserved; //duh |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
171 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
172 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
173 /* Advanced Profile */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
174 int level; //3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
175 int chromaformat; //2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
176 int postprocflag; //frame-based processing use |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
177 int broadcast; //TFF/RFF present |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
178 int interlace; //Progressive/interlaced (RPTFTM syntax element) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
179 int tfcntrflag; //TFCNTR present |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
180 int panscanflag; //NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} presents |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
181 int extended_dmv; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
182 int color_prim; //8 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
183 int transfer_char; //8 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
184 int matrix_coef; //8 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
185 int hrd_param_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
186 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
187 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
188 /* All Profiles */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
189 /* TODO: move all int to flags */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
190 int profile; //2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
191 int frmrtq_postproc; //3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
192 int bitrtq_postproc; //5 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
193 int loopfilter; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
194 int fastuvmc; //Rounding of qpel vector to hpel ? (not in Simple) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
195 int extended_mv; //Ext MV in P/B (not in Simple) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
196 int dquant; //Q varies with MBs, 2bits (not in Simple) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
197 int vstransform; //variable-size transform46 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
198 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
199 int overlap; //overlapped transforms in use |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
200 int quantizer_mode; //2, quantizer mode used for sequence, see QUANT_* |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
201 int finterpflag; //INTERPFRM present |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
202 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
203 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
204 /*****************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
205 /* Frame decoding */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
206 /*****************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
207 /* All profiles */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
208 uint8_t mv_mode, mv_mode2; /* MV coding mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
209 uint8_t pict_type; /* Picture type, mapped on MPEG types */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
210 uint8_t pq, altpq; /* Quantizers */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
211 uint8_t dquantfrm, dqprofile, dqsbedge, dqbilevel; /* pquant parameters */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
212 int width_mb, height_mb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
213 int tile; /* 3x2 if (width_mb%3) else 2x3 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
214 int transacfrm2, transacfrm, transacdctab; //1bit elements |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
215 uint8_t ttmbf, ttfrm; /* Transform type */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
216 uint8_t lumscale, lumshift; /* Luma compensation parameters */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
217 int16_t bfraction; /* Relative position % anchors=> how to scale MVs */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
218 uint8_t halfpq; /* Uniform quant over image and qp+.5 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
219 uint8_t respic; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
220 /* Ranges: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
221 * 0 -> [-64n 63.f] x [-32, 31.f] |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
222 * 1 -> [-128, 127.f] x [-64, 63.f] |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
223 * 2 -> [-512, 511.f] x [-128, 127.f] |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
224 * 3 -> [-1024, 1023.f] x [-256, 255.f] |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
225 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
226 uint8_t mvrange; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
227 uint8_t pquantizer; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
228 VLC *cbpcy_vlc /* Current CBPCY VLC table */, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
229 *mv_diff_vlc /* Current MV Diff VLC table */, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
230 *ttmb_vlc /* Current MB Transform Type VLC table */; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
231 uint8_t *mv_type_mb_plane; /* bitplane for mv_type == "raw" */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
232 uint8_t *skip_mb_plane, /* bitplane for skipped MBs */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
233 *direct_mb_plane; /* bitplane for "direct" MBs */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
234 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
235 /* S/M only ? */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
236 uint8_t rangeredfrm, interpfrm; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
237 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
238 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
239 /* Advanced */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
240 uint8_t fcm; //0->Progressive, 2->Frame-Interlace, 3->Field-Interlace |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
241 uint8_t numpanscanwin; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
242 uint8_t tfcntr; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
243 uint8_t rptfrm, tff, rff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
244 uint8_t topleftx; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
245 uint8_t toplefty; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
246 uint8_t bottomrightx; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
247 uint8_t bottomrighty; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
248 uint8_t rndctrl; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
249 uint8_t uvsamp; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
250 uint8_t postproc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
251 int hrd_num_leaky_buckets; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
252 uint8_t bit_rate_exponent; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
253 uint8_t buffer_size_exponent; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
254 uint8_t *ac_pred_plane; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
255 uint8_t *over_flags_plane; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
256 uint16_t *hrd_rate, *hrd_buffer; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
257 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
258 } VC9Context; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
259 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
260 /* FIXME Slow and ugly */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
261 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
|
262 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
263 int i = 0, tmp = !stop; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
264 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
265 while (i != len && tmp != stop) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
266 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
267 tmp = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
268 i++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
269 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
270 return i; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
271 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
272 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
273 static int init_common(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
274 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
275 static int done = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
276 int i; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
277 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
278 v->mv_type_mb_plane = v->direct_mb_plane = v->skip_mb_plane = NULL; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
279 v->pq = -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
280 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
281 v->ac_pred_plane = v->over_flags_plane = NULL; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
282 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
|
283 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
284 if(!done) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
285 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
286 done = 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
287 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
|
288 vc9_bfraction_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
289 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
|
290 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
|
291 vc9_norm2_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
292 vc9_norm2_codes, 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
293 INIT_VLC(&vc9_cbpcy_i_vlc, VC9_CBPCY_I_VLC_BITS, 64, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
294 vc9_cbpcy_i_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
295 vc9_cbpcy_i_codes, 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
296 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
|
297 vc9_imode_bits, 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
298 vc9_imode_codes, 1, 1, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
299 for(i=0; i<3; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
300 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
308 for (i=0; i<2; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
309 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
310 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
|
311 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
|
312 vc9_mv_diff_codes[i], 2, 2, 1); |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
313 INIT_VLC(&vc9_luma_dc_vlc[i], VC9_LUMA_DC_VLC_BITS, 120, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
314 vc9_luma_dc_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
315 vc9_luma_dc_codes[i], 4, 4, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
316 INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
317 vc9_ttmb_bits[i], 1, 1, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
318 vc9_ttmb_codes[i], 2, 2, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
319 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
320 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
321 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
322 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
323 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
324 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
325 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
326 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
|
327 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
328 int i, num; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
329 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
330 num = get_bits(gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
331 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
332 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
|
333 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
334 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
|
335 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
336 if (!v->hrd_rate) v->hrd_rate = av_malloc(num); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
337 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
|
338 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
339 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
|
340 { |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
341 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
|
342 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
343 if (!v->hrd_buffer) v->hrd_buffer = av_malloc(num); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
344 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
|
345 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
346 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
|
347 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
348 //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
|
349 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
|
350 //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
|
351 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
|
352 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
353 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
|
354 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
355 //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
|
356 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
|
357 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
|
358 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
359 av_log(v, AV_LOG_ERROR, "HDR Rates aren't strictly increasing:" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
360 "%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
|
361 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
362 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
363 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
|
364 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
|
365 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
366 av_log(v, AV_LOG_ERROR, "HDR Buffers aren't decreasing:" |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
367 "%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
|
368 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
369 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
370 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
371 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
372 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
373 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
374 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
|
375 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
376 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
377 int nr, dr, aspect_ratio; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
378 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
383 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
|
384 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
|
385 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
|
386 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
|
387 if (v->reserved) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
388 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
389 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
|
390 v->reserved); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
391 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
392 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
393 if (v->extended_mv) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
394 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
|
395 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
396 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
|
397 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
398 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
|
399 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
|
400 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
|
401 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
402 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
|
403 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
|
404 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
405 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
406 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
|
407 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
408 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
|
409 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
|
410 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
411 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
|
412 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
|
413 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
414 else if (aspect_ratio == 0x0E) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
415 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
416 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
|
417 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
418 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
419 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
420 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
|
421 } |
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 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
424 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
425 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
426 avctx->coded_width = avctx->width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
427 avctx->coded_height = avctx->height; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
428 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
429 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
430 if ( get_bits(gb, 1) /* framerateflag */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
431 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
432 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
|
433 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
434 nr = get_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
435 dr = get_bits(gb, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
436 if (nr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
437 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
438 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
|
439 return -1; |
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 if (nr>5) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
442 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
443 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
|
444 "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
|
445 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
446 if (dr<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
447 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
448 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
|
449 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
450 if (dr>2) |
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 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
|
453 "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
|
454 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
455 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
|
456 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
|
457 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
458 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
459 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
460 nr = get_bits(gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
461 // 0.03125->2048Hz / 0.03125Hz |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
462 avctx->frame_rate = 1000000; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
463 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
|
464 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
465 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
466 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
467 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
|
468 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
469 //Chromacity coordinates of color primaries |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
470 //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
|
471 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
|
472 if (v->color_prim<1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
473 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
474 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
|
475 return -1; |
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 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
|
478 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
479 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
|
480 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
481 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
482 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
483 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
484 //Opto-electronic transfer characteristics |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
485 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
|
486 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
|
487 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
488 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
|
489 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
490 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
491 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
492 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
493 //Matrix coefficient for primariev->YCbCr |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
494 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
|
495 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
|
496 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
|
497 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
498 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
|
499 v->color_prim); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
500 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
501 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
502 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
503 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
504 //Hypothetical reference decoder indicator flag |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
505 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
|
506 if (v->hrd_param_flag) |
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 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
|
509 } |
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 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
|
512 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
513 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
514 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
515 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
516 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
|
517 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
518 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
519 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
520 v->profile = get_bits(gb, 2); |
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_DEBUG, "Profile: %i\n", v->profile); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
522 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
523 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
524 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
525 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
526 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
|
527 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
|
528 if (v->chromaformat != 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
529 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
530 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
|
531 "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
|
532 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
533 } |
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 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
536 #endif |
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 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
|
539 if (v->res_sm) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
540 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
541 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
|
542 "Reserved RES_SM=%i is forbidden\n", v->res_sm); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
543 //return -1; |
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 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
546 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
547 // (fps-2)/4 (->30) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
548 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
|
549 // (bitrate-32kbps)/64kbps |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
550 v->bitrtq_postproc = get_bits(gb, 5); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
551 v->loopfilter = get_bits(gb, 1); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
552 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
553 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
554 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
555 #endif |
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 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
|
558 if (v->res_x8) |
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 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
|
561 "1 for reserved RES_X8 is forbidden\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
562 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
563 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
564 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
|
565 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
|
566 if (!v->res_fasttx) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
567 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
568 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
|
569 "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
|
570 //return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
571 } |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
574 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
|
575 if (!v->profile && !v->fastuvmc) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
576 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
577 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
|
578 "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
|
579 return -1; |
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 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
|
582 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
|
583 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
584 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
|
585 "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
|
586 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
587 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
588 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
|
589 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
|
590 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
591 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
592 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
593 #endif |
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 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
|
596 if (v->res_transtab) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
597 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
598 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
|
599 "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
|
600 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
601 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
602 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
603 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
604 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
|
605 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
606 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
607 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
608 #endif |
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 v->syncmarker = get_bits(gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
611 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
|
612 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
613 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
614 avctx->max_b_frames = get_bits(gb, 3); //common |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
615 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
|
616 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
617 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
618 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
619 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
620 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
621 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
|
622 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
|
623 if (!v->res_rtm_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
624 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
625 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
|
626 "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
|
627 //return -1; |
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 #if TRACE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
630 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
|
631 "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
|
632 "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
|
633 "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
|
634 "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
|
635 v->profile, v->frmrtq_postproc, v->bitrtq_postproc, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
636 v->loopfilter, v->multires, v->fastuvmc, v->extended_mv, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
637 v->rangered, v->vstransform, v->overlap, v->syncmarker, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
638 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
|
639 ); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
640 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
641 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
642 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
643 else decode_advanced_sequence_header(avctx, gb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
644 #endif |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
648 #if HAS_ADVANCED_PROFILE |
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 /* Entry point decoding (Advanced Profile) */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
651 /*****************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
652 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
|
653 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
654 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
655 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
|
656 if (v->profile != PROFILE_ADVANCED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
657 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
658 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
|
659 "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
|
660 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
|
661 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
662 if (v->hrd_param_flag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
663 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
664 //Update buffer fullness |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
665 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
|
666 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
|
667 skip_bits(gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
668 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
669 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
|
670 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
671 //RANGE_MAPY |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
672 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
|
673 skip_bits(gb, 3); |
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 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
|
676 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
677 //RANGE_MAPUV |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
678 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
|
679 skip_bits(gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
680 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
681 if (v->panscanflag) |
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 //NUMPANSCANWIN |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
684 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
|
685 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
|
686 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
687 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
688 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
689 #endif |
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 /* Bitplane decoding */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
693 /******************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
694 #define IMODE_RAW 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
695 #define IMODE_NORM2 1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
696 #define IMODE_DIFF2 2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
697 #define IMODE_NORM6 3 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
698 #define IMODE_DIFF6 4 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
699 #define IMODE_ROWSKIP 5 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
700 #define IMODE_COLSKIP 6 |
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 //FIXME optimize |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
703 static int bitplane_decoding(uint8_t* plane, int width, int height, VC9Context *v) |
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 int imode, x, y, code; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
706 uint8_t invert, *planep = plane; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
707 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
708 invert = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
709 imode = get_vlc2(&v->gb, vc9_imode_vlc.table, VC9_IMODE_VLC_BITS, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
710 av_log(v->avctx, AV_LOG_DEBUG, "Bitplane: imode=%i, invert=%i\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
711 imode, invert); |
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 switch (imode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
714 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
715 case IMODE_RAW: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
716 for (y=0; y<height; y++) |
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 for (x=0; x<width; x++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
719 planep[x] = (-get_bits(&v->gb, 1)); //-1=0xFF |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
720 planep += width; |
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 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
723 case IMODE_DIFF2: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
724 case IMODE_NORM2: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
725 if ((height*width) & 1) *(++planep) = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
726 code = get_vlc2(&v->gb, vc9_norm2_vlc.table, VC9_NORM2_VLC_BITS, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
727 *(++planep) = code&1; //lsb => left |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
728 *(++planep) = code&2; //msb => right - this is a bitplane, so only !0 matters |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
729 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
730 case IMODE_DIFF6: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
731 case IMODE_NORM6: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
732 av_log(v->avctx, AV_LOG_ERROR, "Imode using Norm-6 isn't supported\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
733 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
734 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
735 case IMODE_ROWSKIP: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
736 for (y=0; y<height; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
737 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
738 if (get_bits(&v->gb, 1)) //rowskip |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
739 memset(planep, 0, width); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
740 else for (x=0; x<width; x++) planep[x] = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
741 planep += width; |
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 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
744 case IMODE_COLSKIP: //Teh ugly |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
745 for (x=0; x<width; x++) |
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 planep = plane; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
748 if (get_bits(&v->gb, 1)) //colskip |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
749 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
750 for (y=0; y<height; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
751 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
752 planep[x] = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
753 planep += width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
754 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
755 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
756 else |
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 for (y=0; y<height; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
759 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
760 planep[x] = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
761 planep += width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
762 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
763 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
764 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
765 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
766 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
767 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
768 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
769 /* Applying diff operator */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
770 if (imode == IMODE_DIFF2 || imode == IMODE_DIFF2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
771 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
772 /* And what about j=0 !? */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
773 planep = plane + width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
774 memset(plane, invert, width); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
775 for (y=0; y<height; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
776 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
777 planep[0] = planep[-width]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
778 for (x=1; x<width; x++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
779 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
780 if (planep[x-1] != planep[-width]) planep[x] = invert; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
781 else planep[x] = planep[x-1]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
782 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
783 planep += width; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
784 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
785 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
786 else if (invert) |
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 planep = plane; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
789 for (x=0; x<width*height; x++) planep[x] = !planep[x]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
790 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
791 return 0; |
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 /*****************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
795 /* VOP Dquant decoding */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
796 /*****************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
797 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
|
798 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
799 int pqdiff; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
800 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
801 //variable size |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
802 if (v->dquant == 2) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
803 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
804 pqdiff = get_bits(&v->gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
805 if (pqdiff == 7) v->altpq = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
806 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
|
807 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
808 else |
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 v->dquantfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
811 if ( v->dquantfrm ) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
812 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
813 v->dqprofile = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
814 switch (v->dqprofile) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
815 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
816 case DQPROFILE_SINGLE_EDGE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
817 case DQPROFILE_DOUBLE_EDGES: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
818 v->dqsbedge = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
819 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
820 case DQPROFILE_ALL_MBS: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
821 v->dqbilevel = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
822 default: break; //Forbidden ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
823 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
824 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
|
825 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
826 pqdiff = get_bits(&v->gb, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
827 if (pqdiff == 7) v->altpq = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
828 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
|
829 } |
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 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
832 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
833 } |
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 /*****************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
836 /* All Profiles picture header decoding specific functions */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
837 /* Only pro/epilog differs between Simple/Main and Advanced => check caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
838 /*****************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
839 static int decode_bi_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
840 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
841 /* Very particular case: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
842 - for S/M Profiles, decode_b_picture_header reads BF, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
843 bfraction then determine if this is a BI frame, calling |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
844 this function afterwards |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
845 - for A Profile, PTYPE already tells so and we can go |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
846 directly there |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
847 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
848 int pqindex; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
849 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
850 /* Read the quantization stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
851 pqindex = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
852 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
|
853 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
|
854 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
855 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
856 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
|
857 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
858 if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
859 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
860 v->pquantizer = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
861 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
862 /* Read the MV type/mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
863 if (v->extended_mv == 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
864 v->mvrange = get_prefix(&v->gb, 0, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
865 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
866 /* FIXME: what table are used in that case ? */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
867 v->mv_diff_vlc = &vc9_mv_diff_vlc[0]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
868 v->cbpcy_vlc = &vc9_cbpcy_i_vlc; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
869 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
870 av_log(v->avctx, AV_LOG_DEBUG, "B frame, QP=%i\n", v->pq); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
871 av_log(v->avctx, AV_LOG_ERROR, "BI_TYPE not supported yet\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
872 /* Epilog should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
873 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
874 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
875 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
876 static int decode_b_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
877 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
878 int pqindex; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
879 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
880 /* 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
|
881 if (v->profile == PROFILE_SIMPLE) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
882 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
883 av_log(v, AV_LOG_ERROR, "Found a B frame while in Simple Profile!\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
884 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
885 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
886 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
887 v->bfraction = vc9_bfraction_lut[get_vlc2(&v->gb, vc9_bfraction_vlc.table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
888 VC9_BFRACTION_VLC_BITS, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
889 if (v->bfraction < -1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
890 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
891 av_log(v, AV_LOG_ERROR, "Invalid BFRaction\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
892 return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
893 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
894 else if (!v->bfraction) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
895 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
896 /* We actually have a BI frame */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
897 return decode_bi_picture_header(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
898 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
899 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
900 /* Read the quantization stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
901 pqindex = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
902 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
|
903 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
|
904 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
905 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
906 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
|
907 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
908 if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
909 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
910 v->pquantizer = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
911 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
912 /* Read the MV type/mode */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
913 if (v->extended_mv == 1) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
914 v->mvrange = get_prefix(&v->gb, 0, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
915 v->mv_mode = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
916 if (v->pq < 13) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
917 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
918 if (!v->mv_mode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
919 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
920 v->mv_mode = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
921 if (v->mv_mode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
922 av_log(v, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
923 "mv_mode for lowquant B frame was %i\n", v->mv_mode); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
924 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
925 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
926 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
927 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
928 if (!v->mv_mode) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
929 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
930 if (get_bits(&v->gb, 1)) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
931 av_log(v, AV_LOG_ERROR, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
932 "mv_mode for highquant B frame was %i\n", v->mv_mode); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
933 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
934 v->mv_mode = 1-v->mv_mode; //To match (pq < 13) mapping |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
935 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
936 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
937 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
|
938 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
939 if (bitplane_decoding( v->mv_type_mb_plane, v->width_mb, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
940 v->height_mb, v)<0) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
941 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
942 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
943 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
944 //bitplane |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
945 bitplane_decoding(v->direct_mb_plane, v->width_mb, v->height_mb, v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
946 bitplane_decoding(v->skip_mb_plane, v->width_mb, v->height_mb, v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
947 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
948 /* FIXME: what is actually chosen for B frames ? */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
949 v->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&v->gb, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
950 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&v->gb, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
951 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
952 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
953 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
954 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
955 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
956 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
957 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
958 v->ttmbf = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
959 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
960 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
961 v->ttfrm = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
962 av_log(v, AV_LOG_INFO, "Transform used: %ix%i\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
963 (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
|
964 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
965 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
966 /* Epilog should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
967 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
968 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
969 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
970 static int decode_i_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
971 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
972 int pqindex, status = 0, ac_pred, condover; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
973 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
974 /* 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
|
975 //BF = Buffer Fullness |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
976 if (v->profile <= PROFILE_MAIN && get_bits(&v->gb, 7)) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
977 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
978 av_log(v, AV_LOG_DEBUG, "I BufferFullness not 0\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
979 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
980 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
981 /* Quantizer stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
982 pqindex = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
983 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
|
984 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
|
985 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
986 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
987 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
|
988 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
989 if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
990 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
991 v->pquantizer = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
992 av_log(v->avctx, AV_LOG_DEBUG, "I frame: QP=%i (+%i/2)\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
993 v->pq, v->halfpq); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
994 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
995 if (v->profile <= PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
996 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
997 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
998 if (v->extended_mv) v->mvrange = get_prefix(&v->gb, 0, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
999 if (v->multires) v->respic = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1000 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1001 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1002 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1003 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1004 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1005 if (v->postprocflag) v->postproc = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1006 /* 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
|
1007 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
|
1008 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1009 condover = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1010 if (condover) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1011 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1012 condover = 2+get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1013 if (condover == 3) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1014 status = bitplane_decoding(v->over_flags_plane, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1015 v->width_mb, v->height_mb, v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1016 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1017 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1018 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1019 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1020 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1021 /* Epilog should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1022 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1023 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1024 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1025 static int decode_p_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1026 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1027 /* INTERFRM, FRMCNT, RANGEREDFRM read in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1028 int lowquant, pqindex; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1029 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1030 pqindex = get_bits(&v->gb, 5); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1031 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
|
1032 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
|
1033 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1034 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1035 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
|
1036 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1037 if (pqindex < 9) v->halfpq = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1038 if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1039 v->pquantizer = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1040 av_log(v->avctx, AV_LOG_DEBUG, "P Frame: QP=%i (+%i/2)\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1041 v->pq, v->halfpq); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1042 if (v->extended_mv == 1) v->mvrange = get_prefix(&v->gb, 0, 3); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1043 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1044 if (v->profile > PROFILE_MAIN) |
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 if (v->postprocflag) v->postproc = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1047 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1048 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1049 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1050 if (v->multires) v->respic = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1051 lowquant = (v->pquantizer>12) ? 0 : 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1052 v->mv_mode = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 4)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1053 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
|
1054 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1055 v->mv_mode2 = mv_pmode_table[lowquant][get_prefix(&v->gb, 1, 3)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1056 v->lumscale = get_bits(&v->gb, 6); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1057 v->lumshift = get_bits(&v->gb, 6); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1058 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1059 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1060 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
|
1061 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
|
1062 || 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
|
1063 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1064 if (bitplane_decoding(v->mv_type_mb_plane, v->width_mb, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1065 v->height_mb, v) < 0) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1066 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1067 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1068 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1069 if (bitplane_decoding(v->skip_mb_plane, v->width_mb, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1070 v->height_mb, v) < 0) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1071 return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1072 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1073 /* Hopefully this is correct for P frames */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1074 v->mv_diff_vlc = &vc9_mv_diff_vlc[get_bits(&v->gb, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1075 v->cbpcy_vlc = &vc9_cbpcy_p_vlc[get_bits(&v->gb, 2)]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1076 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1077 if (v->dquant) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1078 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1079 av_log(v->avctx, AV_LOG_INFO, "VOP DQuant info\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1080 vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1081 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1082 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1083 if (v->vstransform) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1084 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1085 v->ttmbf = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1086 if (v->ttmbf) |
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 v->ttfrm = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1089 av_log(v->avctx, AV_LOG_INFO, "Transform used: %ix%i\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1090 (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
|
1091 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1092 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1093 /* Epilog should be done in caller */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1094 return 0; |
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 |
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 static int standard_decode_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1099 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1100 int status = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1101 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1102 if (v->finterpflag) v->interpfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1103 skip_bits(&v->gb, 2); //framecnt unused |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1104 if (v->rangered) v->rangeredfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1105 v->pict_type = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1106 if (v->avctx->max_b_frames && !v->pict_type) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1107 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1108 if (get_bits(&v->gb, 1)) v->pict_type = I_TYPE; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1109 else v->pict_type = P_TYPE; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1110 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1111 else v->pict_type++; //P_TYPE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1112 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1113 switch (v->pict_type) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1114 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1115 case I_TYPE: status = decode_i_picture_header(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1116 case BI_TYPE: status = decode_b_picture_header(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1117 case P_TYPE: status = decode_p_picture_header(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1118 case B_TYPE: status = decode_b_picture_header(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1119 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1120 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1121 if (status == FRAME_SKIPED) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1122 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1123 av_log(v, AV_LOG_INFO, "Skipping frame...\n"); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1124 return status; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1125 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1126 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1127 /* AC/DC Syntax */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1128 v->transacfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1129 if (v->transacfrm) v->transacfrm += get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1130 if (v->pict_type == I_TYPE || v->pict_type == BI_TYPE) |
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 v->transacfrm2 = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1133 if (v->transacfrm2) v->transacfrm2 += get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1134 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1135 v->transacdctab = get_bits(&v->gb, 1); |
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 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1138 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1139 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1140 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1141 #if HAS_ADVANCED_PROFILE |
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 /* Advanced Profile picture header decoding specific functions */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1144 /******************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1145 static int advanced_decode_picture_header(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1146 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1147 static const int type_table[4] = { P_TYPE, B_TYPE, I_TYPE, BI_TYPE }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1148 int type, i, ret; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1149 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1150 if (v->interlace) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1151 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1152 v->fcm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1153 if (v->fcm) v->fcm = 2+get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1154 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1155 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1156 type = get_prefix(&v->gb, 0, 4); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1157 if (type > 4 || type < 0) return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1158 v->pict_type = type_table[type]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1159 av_log(v->avctx, AV_LOG_INFO, "AP Frame Type: %i\n", v->pict_type); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1160 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1161 if (v->tfcntrflag) v->tfcntr = get_bits(&v->gb, 8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1162 if (v->broadcast) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1163 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1164 if (!v->interlace) v->rptfrm = get_bits(&v->gb, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1165 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1166 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1167 v->tff = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1168 v->rff = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1169 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1170 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1171 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1172 if (v->panscanflag) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1173 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1174 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1175 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
|
1176 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1177 v->topleftx[i] = get_bits(&v->gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1178 v->toplefty[i] = get_bits(&v->gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1179 v->bottomrightx[i] = get_bits(&v->gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1180 v->bottomrighty[i] = get_bits(&v->gb, 16); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1181 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1182 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1183 skip_bits(&v->gb, 16*4*v->numpanscanwin); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1184 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1185 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1186 v->rndctrl = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1187 v->uvsamp = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1188 if (v->finterpflag == 1) v->interpfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1189 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1190 switch(v->pict_type) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1191 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1192 case I_TYPE: if (decode_i_picture_header(v) < 0) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1193 case P_TYPE: if (decode_p_picture_header(v) < 0) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1194 case BI_TYPE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1195 case B_TYPE: if (decode_b_picture_header(v) < 0) return FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1196 default: break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1197 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1198 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1199 /* AC/DC Syntax */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1200 v->transacfrm = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1201 if (v->transacfrm) v->transacfrm += get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1202 if (v->pict_type == I_TYPE || v->pict_type == BI_TYPE) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1203 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1204 v->transacfrm2 = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1205 if (v->transacfrm2) v->transacfrm2 += get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1206 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1207 v->transacdctab = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1208 if (v->pict_type == I_TYPE) vop_dquant_decoding(v); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1209 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1210 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1211 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1212 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1213 |
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 /* MacroBlock decoding functions */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1216 /******************************************************************************/ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1217 static int standard_decode_i_mbs(VC9Context *v) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1218 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1219 int x, y, ac_pred, cbpcy; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1220 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1221 /* Select ttmb table depending on pq */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1222 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1223 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1224 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1225 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1226 for (y=0; y<v->height_mb; y++) |
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 for (x=0; x<v->width_mb; x++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1229 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1230 cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1231 VC9_CBPCY_I_VLC_BITS, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1232 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1233 //Decode blocks from that mb wrt cbpcy |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1234 } |
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 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1237 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1238 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1239 #define GET_MQUANT() \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1240 if (v->dquantfrm) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1241 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1242 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
|
1243 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1244 if (v->dqbilevel) \ |
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 mquant = (get_bits(&v->gb, 1)) ? v->pq : v->altpq; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1247 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1248 else \ |
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 mqdiff = get_bits(&v->gb, 3); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1251 if (mqdiff != 7) mquant = v->pq + mqdiff; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1252 else mquant = get_bits(&v->gb, 5); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1253 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1254 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1255 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1256 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1257 /* MVDATA decoding from 8.3.5.2 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1258 #define GET_MVDATA() \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1259 index = 1 + get_vlc2(&v->gb, v->mv_diff_vlc->table, \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1260 VC9_MV_DIFF_VLC_BITS, 2); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1261 if (index > 36) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1262 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1263 mb_has_coeffs = 1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1264 index -= 37; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1265 } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1266 else mb_has_coeffs = 0; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1267 mb_is_intra = 0; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1268 if (!index) { dmv_x = dmv_y = 0; } \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1269 else if (index == 35) \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1270 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1271 dmv_x = get_bits(&v->gb, k_x); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1272 dmv_y = get_bits(&v->gb, k_y); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1273 mb_is_intra = 1; \ |
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 else \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1276 { \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1277 index1 = index%6; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1278 if (hpel_flag && index1 == 5) val = 1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1279 else val = 0; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1280 val = get_bits(&v->gb, size_table[index1] - val); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1281 sign = 0 - (val&1); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1282 dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1283 \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1284 index1 = index/6; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1285 if (hpel_flag && index1 == 5) val = 1; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1286 else val = 0; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1287 val = get_bits(&v->gb, size_table[index1] - val); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1288 sign = 0 - (val&1); \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1289 dmv_y = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1290 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1291 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1292 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
|
1293 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1294 int x, y, current_mb = 0, i; /* MB/Block Position info */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1295 int skip_mb_bit = 0, cbpcy; /* MB/B skip */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1296 int hybrid_pred, ac_pred; /* Prediction types */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1297 int mb_has_coeffs = 1 /* last_flag */, mb_is_intra; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1298 int dmv_x, dmv_y; /* Differential MV components */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1299 int mv_mode_bit = 0; /* mv_mode_bit: 1MV=0, 4MV=0 */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1300 int mqdiff, mquant; /* MB quantization */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1301 int tt_block; /* MB Transform type */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1302 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
|
1303 offset_table[6] = { 0, 1, 3, 7, 15, 31 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1304 int k_x, k_y; /* Long MV fixed bitlength */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1305 int hpel_flag, intra_flag; /* Some MB properties */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1306 int index, index1; /* LUT indices */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1307 int val, sign; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1308 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1309 /* Select ttmb table depending on pq */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1310 if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1311 else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1312 else v->ttmb_vlc = &vc9_ttmb_vlc[2]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1313 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1314 /* Select proper long MV range */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1315 switch (v->mvrange) |
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 case 1: k_x = 10; k_y = 9; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1318 case 2: k_x = 12; k_y = 10; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1319 case 3: k_x = 13; k_y = 11; break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1320 default: /*case 0 too */ k_x = 9; k_y = 8; break; |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1323 hpel_flag = v->mv_mode & 1; //MV_PMODE is HPEL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1324 k_x -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1325 k_y -= hpel_flag; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1326 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1327 for (y=0; y<v->height_mb; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1328 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1329 for (x=0; x<v->width_mb; x++) |
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 if (v->mv_type_mb_plane[current_mb]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1332 mv_mode_bit = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1333 if (0) //skipmb is rawmode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1334 skip_mb_bit = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1335 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
|
1336 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1337 if (!v->skip_mb_plane[current_mb]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1338 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1339 GET_MVDATA(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1340 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1341 /* 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
|
1342 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
|
1343 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
|
1344 hybrid_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1345 if (mb_is_intra && !mb_has_coeffs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1346 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1347 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1348 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1349 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1350 else if (mb_has_coeffs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1351 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1352 if (mb_is_intra) ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1353 cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1354 VC9_CBPCY_P_VLC_BITS, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1355 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1356 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1357 if (!v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1358 v->ttfrm = get_vlc2(&v->gb, v->ttmb_vlc->table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1359 VC9_TTMB_VLC_BITS, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1360 //Decode blocks from that mb wrt cbpcy |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1361 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1362 else //Skipped |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1363 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1364 /* 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
|
1365 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
|
1366 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
|
1367 hybrid_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1368 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1369 } //1MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1370 else //4MV mode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1371 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1372 if (!v->skip_mb_plane[current_mb] /* unskipped MB */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1373 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1374 cbpcy = get_vlc2(&v->gb, v->cbpcy_vlc->table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1375 VC9_CBPCY_P_VLC_BITS, 2); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1376 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
|
1377 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1378 if (cbpcy & (1<<6) /* cbpcy set for this block */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1379 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1380 GET_MVDATA(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1381 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1382 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1383 hybrid_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1384 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1385 if (mb_is_intra /* One of the 4 blocks is intra */ && |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1386 index /* non-zero pred for that block */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1387 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1388 if (!v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1389 tt_block = get_vlc2(&v->gb, v->ttmb_vlc->table, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1390 VC9_TTMB_VLC_BITS, 12); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1391 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1392 /* TODO: Process blocks wrt cbpcy */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1393 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1394 /* Prepare cbpcy for next block */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1395 cbpcy <<= 1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1396 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1397 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1398 else //Skipped MB |
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 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
|
1401 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1402 if (v->mv_mode == MV_PMODE_MIXED_MV /* Hybrid pred */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1403 hybrid_pred = get_bits(&v->gb, 1); |
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 /* FIXME: do something */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1406 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1407 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1408 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1409 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1410 current_mb++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1411 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1412 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1413 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1414 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1415 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
|
1416 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1417 int x, y, current_mb = 0 , last_mb = v->height_mb*v->width_mb, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1418 i /* MB / B postion information */; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1419 int direct_b_bit = 0, skip_mb_bit = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1420 int ac_pred; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1421 int b_mv1 = 0, b_mv2 = 0, b_mv_type = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1422 int mquant, mqdiff; /* MB quant stuff */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1423 int tt_block; /* Block transform type */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1424 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1425 for (y=0; y<v->height_mb; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1426 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1427 for (x=0; x<v->width_mb; x++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1428 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1429 if (v->direct_mb_plane[current_mb]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1430 direct_b_bit = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1431 if (1 /* Skip mode is raw */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1432 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1433 /* FIXME getting tired commenting */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1434 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1435 skip_mb_bit = get_bits(&v->gb, n); //vlc |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1436 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1437 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1438 if (!direct_b_bit) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1439 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1440 if (skip_mb_bit) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1441 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1442 /* FIXME getting tired commenting */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1443 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1444 b_mv_type = get_bits(&v->gb, n); //vlc |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1445 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1446 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1447 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1448 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1449 /* FIXME getting tired commenting */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1450 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1451 b_mv1 = get_bits(&v->gb, n); //VLC |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1452 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1453 if (1 /* b_mv1 isn't intra */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1454 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1455 /* FIXME: actually read it */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1456 b_mv_type = 0; //vlc |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1457 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1458 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1459 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1460 if (!skip_mb_bit) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1461 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1462 if (b_mv1 != last_mb) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1463 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1464 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1465 if (1 /* intra mb */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1466 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1467 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1468 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1469 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1470 if (1 /* forward_mb is interpolate */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1471 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1472 /* FIXME: actually read it */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1473 b_mv2 = 0; //vlc |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1474 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1475 if (1 /* b_mv2 isn't the last */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1476 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1477 if (1 /* intra_mb */) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1478 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1479 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1480 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1481 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1482 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1483 //End1 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1484 /* FIXME getting tired, commenting */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1485 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1486 if (v->ttmbf) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1487 v->ttmb = get_bits(&v->gb, n); //vlc |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1488 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1489 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1490 //End2 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1491 for (i=0; i<6; i++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1492 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1493 /* FIXME: process the block */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1494 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1495 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1496 current_mb++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1497 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1498 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1499 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1500 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1501 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1502 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
|
1503 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1504 int i, x, y, cbpcy, mqdiff, absmq, mquant, ac_pred, condover, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1505 current_mb = 0, over_flags_mb = 0; |
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 for (y=0; y<v->height_mb; y++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1508 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1509 for (x=0; x<v->width_mb; x++) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1510 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1511 if (v->ac_pred_plane[i]) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1512 ac_pred = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1513 if (condover == 3 && v->over_flags_plane) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1514 over_flags_mb = get_bits(&v->gb, 1); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1515 GET_MQUANT(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1516 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1517 current_mb++; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1518 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1519 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1520 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1521 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1522 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1523 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
|
1524 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1525 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1526 GetBitContext gb; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1527 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1528 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
|
1529 avctx->pix_fmt = PIX_FMT_YUV420P; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1530 v->avctx = avctx; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1531 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1532 if (init_common(v) < 0) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1533 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1534 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
|
1535 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1536 int count = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1537 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1538 // looks like WMV3 has a sequence header stored in the extradata |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1539 // advanced sequence header may be before the first frame |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1540 // the last byte of the extradata is a version number, 1 for the |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1541 // samples we can decode |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1542 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1543 init_get_bits(&gb, avctx->extradata, avctx->extradata_size); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1544 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1545 decode_sequence_header(avctx, &gb); |
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 count = avctx->extradata_size*8 - get_bits_count(&gb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1548 if (count>0) |
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 av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1551 count, get_bits(&gb, count)); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1552 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1553 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1554 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1555 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1556 } |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1559 /* Done with header parsing */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1560 //FIXME I feel like this is wrong |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1561 v->width_mb = (avctx->coded_width+15)>>4; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1562 v->height_mb = (avctx->coded_height+15)>>4; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1563 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1564 /* Allocate mb bitplanes */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1565 v->mv_type_mb_plane = (uint8_t *)av_malloc(v->width_mb*v->height_mb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1566 if (!v->mv_type_mb_plane) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1567 v->skip_mb_plane = (uint8_t *)av_malloc(v->width_mb*v->height_mb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1568 if (!v->skip_mb_plane) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1569 v->direct_mb_plane = (uint8_t *)av_malloc(v->width_mb*v->height_mb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1570 if (!v->direct_mb_plane) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1571 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1572 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1573 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1574 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1575 v->over_flags_plane = (uint8_t *)av_malloc(v->width_mb*v->height_mb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1576 if (!v->over_flags_plane) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1577 v->ac_pred_plane = (uint8_t *)av_malloc(v->width_mb*v->height_mb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1578 if (!v->ac_pred_plane) return -1; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1579 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1580 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1581 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1582 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1583 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1584 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1585 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
|
1586 void *data, int *data_size, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1587 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
|
1588 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1589 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1590 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
|
1591 AVFrame *pict = data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1592 uint8_t *tmp_buf; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1593 v->avctx = avctx; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1594 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1595 //buf_size = 0 -> last frame |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1596 if (!buf_size) return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1597 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1598 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
|
1599 avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1600 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
|
1601 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
|
1602 avctx->width, avctx->height); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1603 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1604 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
|
1605 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1606 init_get_bits(&v->gb, buf, buf_size*8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1607 av_log(avctx, AV_LOG_INFO, "Frame: %i bits to decode\n", buf_size*8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1608 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1609 #if HAS_ADVANCED_PROFILE |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1610 if (v->profile > PROFILE_MAIN) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1611 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1612 if (advanced_decode_picture_header(v) == FRAME_SKIPED) return buf_size; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1613 switch(v->pict_type) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1614 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1615 case I_TYPE: ret = advanced_decode_i_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1616 case P_TYPE: ret = decode_p_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1617 case B_TYPE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1618 case BI_TYPE: ret = decode_b_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1619 default: ret = FRAME_SKIPED; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1620 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1621 if (ret == FRAME_SKIPED) return buf_size; //We ignore for now failures |
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 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1624 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1625 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1626 if (standard_decode_picture_header(v) == FRAME_SKIPED) return buf_size; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1627 switch(v->pict_type) |
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 case I_TYPE: ret = standard_decode_i_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1630 case P_TYPE: ret = decode_p_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1631 case B_TYPE: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1632 case BI_TYPE: ret = decode_b_mbs(v); break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1633 default: ret = FRAME_SKIPED; |
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 if (ret == FRAME_SKIPED) return buf_size; |
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 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1638 /* Size of the output data = image */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1639 av_log(avctx, AV_LOG_DEBUG, "Consumed %i/%i bits\n", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1640 get_bits_count(&v->gb), buf_size*8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1641 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1642 else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1643 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1644 #if 0 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1645 // search for IDU's |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1646 // FIXME |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1647 uint32_t scp = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1648 int scs = 0, i = 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1649 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1650 while (i < buf_size) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1651 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1652 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
|
1653 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
|
1654 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1655 if (scp != 0x000001) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1656 break; // eof ? |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1657 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1658 scs = buf[i++]; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1659 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1660 init_get_bits(&v->gb, buf+i, (buf_size-i)*8); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1661 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1662 switch(scs) |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1663 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1664 case 0xf: |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1665 decode_sequence_header(avctx, &v->gb); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1666 break; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1667 // to be finished |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1668 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1669 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1670 i += get_bits_count(&v->gb)*8; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1671 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1672 #else |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1673 av_abort(); |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1674 #endif |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1675 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1676 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1677 *data_size = len; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1678 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1679 /* Fake consumption of all data */ |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1680 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
|
1681 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1682 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1683 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
|
1684 { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1685 VC9Context *v = avctx->priv_data; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1686 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1687 #if HAS_ADVANCED_PROFILE |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
1688 av_freep(&v->hrd_rate); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
1689 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
|
1690 #endif |
2458
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
1691 av_freep(&v->mv_type_mb_plane); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
1692 av_freep(&v->skip_mb_plane); |
915094e3da5d
dont use several 100 mb memory for a tiny 120 element table
michael
parents:
2453
diff
changeset
|
1693 av_freep(&v->direct_mb_plane); |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1694 return 0; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1695 } |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1696 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1697 AVCodec vc9_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1698 "vc9", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1699 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1700 CODEC_ID_VC9, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1701 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1702 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1703 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1704 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1705 vc9_decode_frame, |
2453 | 1706 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1707 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1708 }; |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1709 |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1710 AVCodec wmv3_decoder = { |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1711 "wmv3", |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1712 CODEC_TYPE_VIDEO, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1713 CODEC_ID_WMV3, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1714 sizeof(VC9Context), |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1715 vc9_decode_init, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1716 NULL, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1717 vc9_decode_end, |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1718 vc9_decode_frame, |
2453 | 1719 CODEC_CAP_DELAY, |
2445
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1720 NULL |
96da66323faa
preliminary vc9 bitstream decoder, committing to make syncing and team-work on it easier
alex
parents:
diff
changeset
|
1721 }; |