Guest User

Untitled

a guest
Oct 23rd, 2017
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.15 KB | None | 0 0
  1. From 985c0a3bc2a20c1537eea53c58da41ab7bf3a6b4 Mon Sep 17 00:00:00 2001
  2. From: Mashiat Sarker <shahriman_ams@yahoo.com>
  3. Date: Sun, 26 Jun 2011 21:20:27 +0600
  4. Subject: [PATCH] Field picture detection and header parsing 01
  5.  
  6. ---
  7. libavcodec/vc1.c | 173 +++++++++++++++++++++++++++++++++-----------------
  8. libavcodec/vc1.h | 10 +++
  9. libavcodec/vc1data.c | 48 ++++++++++++++
  10. libavcodec/vc1data.h | 10 +++
  11. libavcodec/vc1dec.c | 13 ++++
  12. 5 files changed, 195 insertions(+), 59 deletions(-)
  13.  
  14. diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
  15. index 0884428..dc9859c 100644
  16. --- a/libavcodec/vc1.c
  17. +++ b/libavcodec/vc1.c
  18. @@ -116,7 +116,7 @@ static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
  19. int width, height, stride;
  20.  
  21. width = v->s.mb_width;
  22. - height = v->s.mb_height;
  23. + height = v->s.mb_height >> (v->fcm == 2);
  24. stride = v->s.mb_stride;
  25. invert = get_bits1(gb);
  26. imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
  27. @@ -797,6 +797,13 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  28. int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
  29.  
  30. v->p_frame_skipped = 0;
  31. + if (v->second_field) {
  32. + v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
  33. + if (v->fptype & 4)
  34. + v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
  35. + av_log(s->avctx, AV_LOG_DEBUG, "Field 2: AV_PICTURE_TYPE_* = %d\n", v->s.pict_type);
  36. + goto parse_common_field_info;
  37. + }
  38.  
  39. if(v->interlace){
  40. v->fcm = decode012(gb);
  41. @@ -806,30 +813,39 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  42. }
  43. }
  44.  
  45. - switch(get_unary(gb, 0, 4)) {
  46. - case 0:
  47. - v->s.pict_type = AV_PICTURE_TYPE_P;
  48. - av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_P\n");
  49. - break;
  50. - case 1:
  51. - v->s.pict_type = AV_PICTURE_TYPE_B;
  52. - av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_B\n");
  53. - break;
  54. - case 2:
  55. - v->s.pict_type = AV_PICTURE_TYPE_I;
  56. - av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_I\n");
  57. - break;
  58. - case 3:
  59. - v->s.pict_type = AV_PICTURE_TYPE_BI;
  60. - av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_BI\n");
  61. - break;
  62. - case 4:
  63. - v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic
  64. - v->p_frame_skipped = 1;
  65. - av_log(v->s.avctx, AV_LOG_DEBUG, "Skipped Picture\n");
  66. - return 0;
  67. + if (v->fcm == 2) {
  68. + v->s.linesize <<= 1;
  69. + v->s.uvlinesize <<= 1;
  70. + v->fptype = get_bits(gb, 3);
  71. + av_log(s->avctx, AV_LOG_DEBUG, "FPTYPE: %d\n", v->fptype);
  72. + v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
  73. + if (v->fptype & 4) // B-picture
  74. + v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
  75. + } else {
  76. + switch(get_unary(gb, 0, 4)) {
  77. + case 0:
  78. + v->s.pict_type = AV_PICTURE_TYPE_P;
  79. + av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_P\n");
  80. + break;
  81. + case 1:
  82. + v->s.pict_type = AV_PICTURE_TYPE_B;
  83. + av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_B\n");
  84. + break;
  85. + case 2:
  86. + v->s.pict_type = AV_PICTURE_TYPE_I;
  87. + av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_I\n");
  88. + break;
  89. + case 3:
  90. + v->s.pict_type = AV_PICTURE_TYPE_BI;
  91. + av_log(v->s.avctx, AV_LOG_DEBUG, "AV_PICTURE_TYPE_BI\n");
  92. + break;
  93. + case 4:
  94. + v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic
  95. + v->p_frame_skipped = 1;
  96. + av_log(v->s.avctx, AV_LOG_DEBUG, "Skipped Picture\n");
  97. + return 0;
  98. + }
  99. }
  100. -
  101. if(v->tfcntrflag)
  102. skip_bits(gb, 8);
  103. if(v->broadcast) {
  104. @@ -847,6 +863,22 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  105. v->rnd = get_bits1(gb);
  106. if(v->interlace)
  107. v->uvsamp = get_bits1(gb);
  108. + if (v->fcm == 2) {
  109. + if (!v->refdist_flag) v->refdist = 0;
  110. + else {
  111. + if ((v->s.pict_type != AV_PICTURE_TYPE_B)
  112. + && (v->s.pict_type != AV_PICTURE_TYPE_BI)) {
  113. + v->refdist = get_bits(gb, 2);
  114. + if (val == 3) v->refdist += get_unary(gb, 0, 16);
  115. + av_log(s->avctx, AV_LOG_DEBUG, "REFDIST: %d\n", v->refdist);
  116. + } else {
  117. + v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
  118. + v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index];
  119. + av_log(s->avctx, AV_LOG_DEBUG, "BFRACTION: %d\n", v->bfraction);
  120. + }
  121. + }
  122. + goto parse_common_field_info;
  123. + }
  124. if(v->finterpflag) v->interpfrm = get_bits1(gb);
  125. if(v->s.pict_type == AV_PICTURE_TYPE_B) {
  126. v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1);
  127. @@ -855,6 +887,8 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  128. v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
  129. }
  130. }
  131. +
  132. + parse_common_field_info:
  133. pqindex = get_bits(gb, 5);
  134. if(!pqindex) return -1;
  135. v->pqindex = pqindex;
  136. @@ -890,7 +924,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  137. if (status < 0) return -1;
  138. av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: "
  139. "Imode: %i, Invert: %i\n", status>>1, status&1);
  140. - }
  141. + }
  142. status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
  143. if (status < 0) return -1;
  144. av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
  145. @@ -907,13 +941,14 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  146. }
  147. break;
  148. case AV_PICTURE_TYPE_P:
  149. + if (v->fcm == 2)
  150. + if (v->numref = get_bits1(gb)) v->reffield = get_bits1(gb);
  151. if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3);
  152. else v->mvrange = 0;
  153. if (v->interlace) {
  154. if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3);
  155. else v->dmvrange = 0;
  156. - switch (v->fcm) {
  157. - case 1: // interlaced frame picture
  158. + if (v->fcm == 1) { // interlaced frame picture
  159. v->fourmvswitch = get_bits1(gb);
  160. av_log(v->s.avctx, AV_LOG_DEBUG, "4MVSWITCH: %d\n", v->fourmvswitch);
  161. v->intcomp = get_bits1(gb);
  162. @@ -932,10 +967,6 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  163. imvtab = get_bits(gb, 2);
  164. av_log(v->s.avctx, AV_LOG_DEBUG, "MVTAB: %d\n", imvtab);
  165. v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
  166. - break;
  167. - case 2: // interlaced field picture
  168. - // ... later
  169. - break;
  170. }
  171. // interlaced p-picture cbpcy range is [1, 63]
  172. icbptab = get_bits(gb, 3);
  173. @@ -951,42 +982,48 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  174. v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
  175. }
  176. }
  177. - if (!v->interlace || (v->fcm == 1)) {
  178. - v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
  179. - v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
  180. - v->range_x = 1 << (v->k_x - 1);
  181. - v->range_y = 1 << (v->k_y - 1);
  182. - }
  183. + v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
  184. + v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
  185. + v->range_x = 1 << (v->k_x - 1);
  186. + v->range_y = 1 << (v->k_y - 1);
  187. //choose one of the three tables to decode TTMB
  188. if (v->pq < 5) v->tt_index = 0;
  189. else if(v->pq < 13) v->tt_index = 1;
  190. else v->tt_index = 2;
  191. //
  192. - if (!v->interlace) {
  193. + if (v->fcm != 1) {
  194. lowquant = (v->pq > 12) ? 0 : 1;
  195. v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
  196. if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
  197. int scale, shift, i;
  198. v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
  199. + if (v->fcm == 2) v->intcompfield = decode210(gb);
  200. v->lumscale = get_bits(gb, 6);
  201. v->lumshift = get_bits(gb, 6);
  202. /* fill lookup tables for intensity compensation */
  203. - if(!v->lumscale) {
  204. - scale = -64;
  205. - shift = (255 - v->lumshift * 2) << 6;
  206. - if(v->lumshift > 31)
  207. - shift += 128 << 6;
  208. - } else {
  209. - scale = v->lumscale + 32;
  210. - if(v->lumshift > 31)
  211. - shift = (v->lumshift - 64) << 6;
  212. - else
  213. - shift = v->lumshift << 6;
  214. - }
  215. - for(i = 0; i < 256; i++) {
  216. - v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
  217. - v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
  218. + #define INIT_LUT(_lumscale, _lumshift, _luty, _lutuv) \
  219. + if(!_lumscale) { \
  220. + scale = -64; \
  221. + shift = (255 - _lumshift * 2) << 6; \
  222. + if(_lumshift > 31) \
  223. + shift += 128 << 6; \
  224. + } else { \
  225. + scale = _lumscale + 32; \
  226. + if(_lumshift > 31) \
  227. + shift = (_lumshift - 64) << 6; \
  228. + else \
  229. + shift = _lumshift << 6; \
  230. + } \
  231. + for(i = 0; i < 256; i++) { \
  232. + _luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); \
  233. + _lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6); \
  234. }
  235. + INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv);
  236. + if ((v->fcm == 2) && !v->intcompfield) {
  237. + v->lumscale2 = get_bits(gb, 6);
  238. + v->lumshift2 = get_bits(gb, 6);
  239. + INIT_LUT(v->lumscale2, v->lumshift2, v->luty2, v->lutuv2);
  240. + }
  241. v->use_ic = 1;
  242. }
  243. if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
  244. @@ -999,7 +1036,8 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  245. } else
  246. v->s.quarter_sample = 1;
  247. v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
  248. -
  249. + }
  250. + if (!v->fcm) { // progressive
  251. if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
  252. v->mv_mode2 == MV_PMODE_MIXED_MV)
  253. || v->mv_mode == MV_PMODE_MIXED_MV)
  254. @@ -1020,11 +1058,28 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
  255. /* Hopefully this is correct for P frames */
  256. v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
  257. v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
  258. - } else {
  259. - if (v->fcm == 1) {
  260. - v->s.quarter_sample = 1;
  261. - v->s.mspel = 1;
  262. - }
  263. + } else if (v->fcm == 1) { // frame interlaced
  264. + v->s.quarter_sample = 1;
  265. + v->s.mspel = 1;
  266. + } else { // field interlaced
  267. + mbmodetab = get_bits(gb, 3);
  268. + av_log(v->s.avctx, AV_LOG_DEBUG, "MBMODETAB: %d\n", mbmodetab);
  269. + imvtab = get_bits(gb, 2 + v->numref);
  270. + av_log(v->s.avctx, AV_LOG_DEBUG, "IMVTAB: %d\n", imvtab);
  271. + if (!numref)
  272. + v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
  273. + else
  274. + v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
  275. + icbptab = get_bits(gb, 3);
  276. + v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
  277. + if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
  278. + v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {
  279. + fourmvbptab = get_bits(gb, 2);
  280. + v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
  281. + v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
  282. + } else {
  283. + v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
  284. + }
  285. }
  286. if (v->dquant)
  287. {
  288. diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
  289. index 1b34f63..717b590 100644
  290. --- a/libavcodec/vc1.h
  291. +++ b/libavcodec/vc1.h
  292. @@ -325,6 +325,7 @@ typedef struct VC1Context{
  293. int intcomp;
  294. uint8_t lumscale2; ///< for interlaced field P picture
  295. uint8_t lumshift2;
  296. + uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation
  297. VLC* mbmode_vlc;
  298. VLC* imv_vlc;
  299. VLC* twomvbp_vlc;
  300. @@ -336,6 +337,15 @@ typedef struct VC1Context{
  301. int8_t zzi_8x8[64];
  302. uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV
  303. int frame_num; // keeps count of frame (debugging)
  304. + int fptype;
  305. + int second_field;
  306. + int refdist; ///< distance of the current picture from reference
  307. + int numref; ///< number of past field pictures used as reference
  308. + // 0 corresponds to 1 and 1 corresponds to 2 references
  309. + int reffield; ///< if numref = 0 (1 reference) then reffield decides which
  310. + // field to use among the two fields from previous frame
  311. + int intcompfield; ///< which of the two fields to be intensity compensated
  312. + // 0: both fields, 1: bottom field, 2: top field
  313.  
  314. /** Frame decoding info for sprite modes */
  315. //@{
  316. diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
  317. index 1f43127..2ca8162 100644
  318. --- a/libavcodec/vc1data.c
  319. +++ b/libavcodec/vc1data.c
  320. @@ -132,6 +132,10 @@ VLC ff_vc1_subblkpat_vlc[3];
  321. VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
  322. #define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
  323. VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
  324. +#define VC1_IF_MMV_MBMODE_VLC_BITS 5
  325. +VLC ff_vc1_if_mmv_mbmode_vlc[8];
  326. +#define VC1_IF_1MV_MBMODE_VLC_BITS 5
  327. +VLC ff_vc1_if_1mv_mbmode_vlc[8];
  328. #define VC1_1REF_MVDATA_VLC_BITS 9
  329. VLC ff_vc1_1ref_mvdata_vlc[4];
  330. #define VC1_2REF_MVDATA_VLC_BITS 9
  331. @@ -356,6 +360,50 @@ const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9] = {
  332. { 4, 8, 1, 3, 7, 5, 6, 2, 8}
  333. };
  334.  
  335. +/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
  336. +/* mixed-MV */
  337. +const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = {
  338. + { 16, 17, 3, 3, 0, 5, 9, 2 },
  339. + { 8, 9, 3, 6, 7, 0, 5, 2 },
  340. + { 16, 17, 5, 3, 0, 3, 9, 2 },
  341. + { 56, 57, 15, 4, 5, 6, 29, 0 },
  342. + { 52, 53, 27, 14, 15, 2, 12, 0 },
  343. + { 56, 57, 29, 5, 6, 0, 15, 4 },
  344. + { 16, 17, 6, 7, 0, 1, 9, 5 },
  345. + { 56, 57, 0, 5, 6, 29, 4, 15 }
  346. +};
  347. +const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = {
  348. + { 6, 6, 2, 3, 2, 4, 5, 2 },
  349. + { 5, 5, 3, 3, 3, 2, 4, 2 },
  350. + { 6, 6, 4, 3, 2, 2, 5, 2 },
  351. + { 6, 6, 4, 3, 3, 3, 5, 1 },
  352. + { 6, 6, 5, 4, 4, 2, 4, 1 },
  353. + { 6, 6, 5, 3, 3, 1, 4, 3 },
  354. + { 5, 5, 3, 3, 2, 2, 4, 3 },
  355. + { 6, 6, 1, 3, 3, 5, 3, 4 }
  356. +};
  357. +/* 1MV */
  358. +const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6] = {
  359. + { 0, 1, 1, 1, 1, 1 },
  360. + { 0, 1, 1, 1, 1, 1 },
  361. + { 16, 17, 3, 0, 9, 5 },
  362. + { 20, 21, 3, 11, 0, 4 },
  363. + { 4, 5, 2, 3, 3, 0 },
  364. + { 4, 5, 3, 2, 0, 3 },
  365. + { 0, 1, 1, 1, 1, 1 },
  366. + { 16, 17, 9, 5, 3, 0 }
  367. +};
  368. +const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6] = {
  369. + { 5, 5, 1, 3, 2, 4 },
  370. + { 5, 5, 1, 2, 3, 4 },
  371. + { 5, 5, 2, 1, 4, 3 },
  372. + { 5, 5, 2, 4, 1, 3 },
  373. + { 4, 4, 2, 3, 2, 2 },
  374. + { 4, 4, 3, 2, 2, 2 },
  375. + { 5, 5, 3, 4, 1, 2 },
  376. + { 5, 5, 4, 3, 2, 1 }
  377. +};
  378. +
  379. /* Interlaced frame/field picture MVDATA VLC tables */
  380.  
  381. /* 1-reference tables */
  382. diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
  383. index 3cbe133..37656e8 100644
  384. --- a/libavcodec/vc1data.h
  385. +++ b/libavcodec/vc1data.h
  386. @@ -80,6 +80,10 @@ extern VLC ff_vc1_subblkpat_vlc[3];
  387. extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
  388. #define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
  389. extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
  390. +#define VC1_IF_MMV_MBMODE_VLC_BITS 5
  391. +extern VLC ff_vc1_if_mmv_mbmode_vlc[8];
  392. +#define VC1_IF_1MV_MBMODE_VLC_BITS 5
  393. +extern VLC ff_vc1_if_1mv_mbmode_vlc[8];
  394. #define VC1_1REF_MVDATA_VLC_BITS 9
  395. extern VLC ff_vc1_1ref_mvdata_vlc[4];
  396. #define VC1_2REF_MVDATA_VLC_BITS 9
  397. @@ -170,6 +174,12 @@ extern const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15];
  398. extern const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9];
  399. extern const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9];
  400.  
  401. +/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
  402. +extern const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8];
  403. +extern const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8];
  404. +extern const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6];
  405. +extern const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6];
  406. +
  407. /* Interlaced frame/field picture MVDATA VLC tables */
  408. /* 1-reference tables */
  409. extern const uint32_t ff_vc1_1ref_mvdata_codes[4][72];
  410. diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
  411. index 28b0c49..36e36d8 100644
  412. --- a/libavcodec/vc1dec.c
  413. +++ b/libavcodec/vc1dec.c
  414. @@ -4237,6 +4237,8 @@ static int vc1_decode_frame(AVCodecContext *avctx,
  415. MpegEncContext *s = &v->s;
  416. AVFrame *pict = data;
  417. uint8_t *buf2 = NULL;
  418. + uint8_t *buf_field2 = NULL;
  419. + int buf_field2_size, field_mode = 0;
  420. const uint8_t *buf_start = buf;
  421. struct {
  422. uint8_t *buf;
  423. @@ -4293,6 +4295,10 @@ static int vc1_decode_frame(AVCodecContext *avctx,
  424. buf_start = start;
  425. buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
  426. break;
  427. + case VC1_CODE_FIELD:
  428. + buf_field2_size = vc1_unescape_buffer(start + 4, size, buf_field2);
  429. + field_mode = 1;
  430. + break;
  431. case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
  432. buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
  433. init_get_bits(&s->gb, buf2, buf_size2*8);
  434. @@ -4407,6 +4413,13 @@ static int vc1_decode_frame(AVCodecContext *avctx,
  435. vc1_decode_blocks(v);
  436. if (i != n_slices) s->gb = slices[i].gb;
  437. }
  438. + if (field_mode) {
  439. + v->second_field = 1;
  440. + init_get_bits(&s->gb, buf_field2, buf_field2_size*8);
  441. + if(vc1_parse_frame_header_adv(v, &s->gb) == -1) goto err;
  442. + vc1_decode_blocks(v);
  443. + v->second_field = 0;
  444. + }
  445. //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), s->gb.size_in_bits);
  446. // if(get_bits_count(&s->gb) > buf_size * 8)
  447. // return -1;
  448. --
  449. 1.7.4.1
Add Comment
Please, Sign In to add comment