History

avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx

Andreas Rheinhardt committed 1 year ago

Commit 7db62671 parent f1c56c010 files · +86 −80Browse files

Unified · Split

10 files
  1. libavcodec/flvdec.c +2 −2
  2. libavcodec/h263dec.c +14 −14
  3. libavcodec/h263dec.h +20 −0
  4. libavcodec/intelh263dec.c +4 −4
  5. libavcodec/ituh263dec.c +20 −20
  6. libavcodec/mpeg4videodec.c +19 −17
  7. libavcodec/mpegvideo.h +0 −15
  8. libavcodec/mpegvideo_dec.c +0 −1
  9. libavcodec/nvdec_mpeg4.c +1 −1
  10. libavcodec/rv10.c +6 −6
libavcodec/flvdec.c+2−2
@@ -89,13 +89,13 @@ int ff_flv_decode_picture_header(H263DecContext *const h) · 88 unmodified lines
89 skip_bits1(&h->gb); /* deblocking flag */89 skip_bits1(&h->gb); /* deblocking flag */
90 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);90 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
91 91
92 h->c.h263_long_vectors = 0;92 h->h263_long_vectors = 0;
93 93
94 /* PEI */94 /* PEI */
95 if (skip_1stop_8data_bits(&h->gb) < 0)95 if (skip_1stop_8data_bits(&h->gb) < 0)
96 return AVERROR_INVALIDDATA;96 return AVERROR_INVALIDDATA;
97 97
98 if (h->c.ehc_mode)98 if (h->ehc_mode)
99 h->c.avctx->sample_aspect_ratio= (AVRational){1,2};99 h->c.avctx->sample_aspect_ratio= (AVRational){1,2};
100 100
101 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {101 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO) {
libavcodec/h263dec.c+14−14
@@ -157,7 +157,7 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) · 156 unmodified lines
157 157
158 if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263"))158 if (avctx->codec_tag == AV_RL32("L263") || avctx->codec_tag == AV_RL32("S263"))
159 if (avctx->extradata_size == 56 && avctx->extradata[0] == 1)159 if (avctx->extradata_size == 56 && avctx->extradata[0] == 1)
160 s->ehc_mode = 1;160 h->ehc_mode = 1;
161 161
162 /* for H.263, we allocate the images after having read the header */162 /* for H.263, we allocate the images after having read the header */
163 if (avctx->codec->id != AV_CODEC_ID_H263 &&163 if (avctx->codec->id != AV_CODEC_ID_H263 &&
@@ -279,7 +279,7 @@ static int decode_slice(H263DecContext *const h) · 115 unmodified lines
279 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,279 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y,
280 h->c.mb_x, h->c.mb_y, ER_MB_END & part_mask);280 h->c.mb_x, h->c.mb_y, ER_MB_END & part_mask);
281 281
282 h->c.padding_bug_score--;282 h->padding_bug_score--;
283 283
284 if (++h->c.mb_x >= h->c.mb_width) {284 if (++h->c.mb_x >= h->c.mb_width) {
285 h->c.mb_x = 0;285 h->c.mb_x = 0;
@@ -324,7 +324,7 @@ static int decode_slice(H263DecContext *const h) · 38 unmodified lines
324 get_bits_left(&h->gb) >= 48 &&324 get_bits_left(&h->gb) >= 48 &&
325 show_bits(&h->gb, 24) == 0x4010 &&325 show_bits(&h->gb, 24) == 0x4010 &&
326 !h->c.data_partitioning)326 !h->c.data_partitioning)
327 h->c.padding_bug_score += 32;327 h->padding_bug_score += 32;
328 328
329 /* try to detect the padding bug */329 /* try to detect the padding bug */
330 if (h->c.codec_id == AV_CODEC_ID_MPEG4 &&330 if (h->c.codec_id == AV_CODEC_ID_MPEG4 &&
@@ -336,18 +336,18 @@ static int decode_slice(H263DecContext *const h) · 5 unmodified lines
336 const int bits_left = h->gb.size_in_bits - bits_count;336 const int bits_left = h->gb.size_in_bits - bits_count;
337 337
338 if (bits_left == 0) {338 if (bits_left == 0) {
339 h->c.padding_bug_score += 16;339 h->padding_bug_score += 16;
340 } else if (bits_left != 1) {340 } else if (bits_left != 1) {
341 int v = show_bits(&h->gb, 8);341 int v = show_bits(&h->gb, 8);
342 v |= 0x7F >> (7 - (bits_count & 7));342 v |= 0x7F >> (7 - (bits_count & 7));
343 343
344 if (v == 0x7F && bits_left <= 8)344 if (v == 0x7F && bits_left <= 8)
345 h->c.padding_bug_score--;345 h->padding_bug_score--;
346 else if (v == 0x7F && ((get_bits_count(&h->gb) + 8) & 8) &&346 else if (v == 0x7F && ((get_bits_count(&h->gb) + 8) & 8) &&
347 bits_left <= 16)347 bits_left <= 16)
348 h->c.padding_bug_score += 4;348 h->padding_bug_score += 4;
349 else349 else
350 h->c.padding_bug_score++;350 h->padding_bug_score++;
351 }351 }
352 }352 }
353 353
@@ -359,7 +359,7 @@ static int decode_slice(H263DecContext *const h) · 5 unmodified lines
359 show_bits(&h->gb, 8) == 0 &&359 show_bits(&h->gb, 8) == 0 &&
360 !h->c.data_partitioning) {360 !h->c.data_partitioning) {
361 361
362 h->c.padding_bug_score += 32;362 h->padding_bug_score += 32;
363 }363 }
364 364
365 if (h->c.codec_id == AV_CODEC_ID_H263 &&365 if (h->c.codec_id == AV_CODEC_ID_H263 &&
@@ -367,12 +367,12 @@ static int decode_slice(H263DecContext *const h) · 1 unmodified line
367 get_bits_left(&h->gb) >= 64 &&367 get_bits_left(&h->gb) >= 64 &&
368 AV_RB64(h->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {368 AV_RB64(h->gb.buffer_end - 8) == 0xCDCDCDCDFC7F0000) {
369 369
370 h->c.padding_bug_score += 32;370 h->padding_bug_score += 32;
371 }371 }
372 372
373 if (h->c.workaround_bugs & FF_BUG_AUTODETECT) {373 if (h->c.workaround_bugs & FF_BUG_AUTODETECT) {
374 if (374 if (
375 (h->c.padding_bug_score > -2 && !h->c.data_partitioning))375 (h->padding_bug_score > -2 && !h->c.data_partitioning))
376 h->c.workaround_bugs |= FF_BUG_NO_PADDING;376 h->c.workaround_bugs |= FF_BUG_NO_PADDING;
377 else377 else
378 h->c.workaround_bugs &= ~FF_BUG_NO_PADDING;378 h->c.workaround_bugs &= ~FF_BUG_NO_PADDING;
@@ -410,7 +410,7 @@ static int decode_slice(H263DecContext *const h) · 31 unmodified lines
410 410
411 av_log(h->c.avctx, AV_LOG_ERROR,411 av_log(h->c.avctx, AV_LOG_ERROR,
412 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",412 "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
413 get_bits_left(&h->gb), show_bits(&h->gb, 24), h->c.padding_bug_score);413 get_bits_left(&h->gb), show_bits(&h->gb, 24), h->padding_bug_score);
414 414
415 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, h->c.mb_x, h->c.mb_y,415 ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, h->c.mb_x, h->c.mb_y,
416 ER_MB_END & part_mask);416 ER_MB_END & part_mask);
@@ -432,10 +432,10 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 15 unmodified lines
432 /* no supplementary picture */432 /* no supplementary picture */
433 if (buf_size == 0) {433 if (buf_size == 0) {
434 /* special case for last picture */434 /* special case for last picture */
435 if ((!h->c.low_delay || h->c.skipped_last_frame) && h->c.next_pic.ptr) {435 if ((!h->c.low_delay || h->skipped_last_frame) && h->c.next_pic.ptr) {
436 if ((ret = av_frame_ref(pict, h->c.next_pic.ptr->f)) < 0)436 if ((ret = av_frame_ref(pict, h->c.next_pic.ptr->f)) < 0)
437 return ret;437 return ret;
438 if (h->c.skipped_last_frame) {438 if (h->skipped_last_frame) {
439 /* If the stream ended with an NVOP, we output the last frame439 /* If the stream ended with an NVOP, we output the last frame
440 * in display order, but with the props from the last input440 * in display order, but with the props from the last input
441 * packet so that the stream's end time is correct. */441 * packet so that the stream's end time is correct. */
@@ -549,7 +549,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 107 unmodified lines
549 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)549 if ((ret = ff_mpv_frame_start(s, avctx)) < 0)
550 return ret;550 return ret;
551 551
552 if (!h->c.divx_packed)552 if (!h->divx_packed)
553 ff_thread_finish_setup(avctx);553 ff_thread_finish_setup(avctx);
554 554
555 if (avctx->hwaccel) {555 if (avctx->hwaccel) {
libavcodec/h263dec.h+20−0
@@ -50,6 +50,26 @@ typedef struct H263DecContext { · 49 unmodified lines
50 50
51 GetBitContext gb;51 GetBitContext gb;
52 52
53 int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
54
55 /* motion compensation */
56 int h263_long_vectors; ///< use horrible H.263v1 long vector mode
57
58 /* H.263 specific */
59 int ehc_mode;
60
61 /* H.263+ specific */
62 int custom_pcf;
63
64 /* MPEG-4 specific */
65 int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4
66 int skipped_last_frame;
67 int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
68
69 /* RV10 specific */
70 int rv10_version; ///< RV10 version: 0 or 3
71 int rv10_first_dc_coded[3];
72
53 int (*decode_mb)(struct H263DecContext *h);73 int (*decode_mb)(struct H263DecContext *h);
54 74
55 GetBitContext last_resync_gb; ///< used to search for the next resync marker75 GetBitContext last_resync_gb; ///< used to search for the next resync marker
libavcodec/intelh263dec.c+4−4
@@ -60,14 +60,14 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 59 unmodified lines
60 60
61 h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);61 h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
62 62
63 h->c.h263_long_vectors = get_bits1(&h->gb);63 h->h263_long_vectors = get_bits1(&h->gb);
64 64
65 if (get_bits1(&h->gb) != 0) {65 if (get_bits1(&h->gb) != 0) {
66 av_log(h->c.avctx, AV_LOG_ERROR, "SAC not supported\n");66 av_log(h->c.avctx, AV_LOG_ERROR, "SAC not supported\n");
67 return -1; /* SAC: off */67 return -1; /* SAC: off */
68 }68 }
69 h->c.obmc = get_bits1(&h->gb);69 h->c.obmc = get_bits1(&h->gb);
70 h->c.pb_frame = get_bits1(&h->gb);70 h->pb_frame = get_bits1(&h->gb);
71 71
72 if (format < 6) {72 if (format < 6) {
73 h->c.width = ff_h263_format[format][0];73 h->c.width = ff_h263_format[format][0];
@@ -86,7 +86,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 12 unmodified lines
86 if (get_bits1(&h->gb))86 if (get_bits1(&h->gb))
87 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");87 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
88 if (get_bits1(&h->gb))88 if (get_bits1(&h->gb))
89 h->c.pb_frame = 2;89 h->pb_frame = 2;
90 if (get_bits(&h->gb, 5))90 if (get_bits(&h->gb, 5))
91 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");91 av_log(h->c.avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
92 if (get_bits(&h->gb, 5) != 1)92 if (get_bits(&h->gb, 5) != 1)
@@ -110,7 +110,7 @@ int ff_intel_h263_decode_picture_header(H263DecContext *const h) · 17 unmodified lines
110 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);110 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
111 skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */111 skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
112 112
113 if (h->c.pb_frame) {113 if (h->pb_frame) {
114 skip_bits(&h->gb, 3); //temporal reference for B-frame114 skip_bits(&h->gb, 3); //temporal reference for B-frame
115 skip_bits(&h->gb, 2); //dbquant115 skip_bits(&h->gb, 2); //dbquant
116 }116 }
libavcodec/ituh263dec.c+20−20
@@ -85,7 +85,7 @@ void ff_h263_show_pict_info(H263DecContext *const h, int h263_plus) · 84 unmodified lines
85 h->gb.size_in_bits, 1-h->c.no_rounding,85 h->gb.size_in_bits, 1-h->c.no_rounding,
86 h->c.obmc ? " AP" : "",86 h->c.obmc ? " AP" : "",
87 h->c.umvplus ? " UMV" : "",87 h->c.umvplus ? " UMV" : "",
88 h->c.h263_long_vectors ? " LONG" : "",88 h->h263_long_vectors ? " LONG" : "",
89 h263_plus ? " +" : "",89 h263_plus ? " +" : "",
90 h->c.h263_aic ? " AIC" : "",90 h->c.h263_aic ? " AIC" : "",
91 h->c.alt_inter_vlc ? " AIV" : "",91 h->c.alt_inter_vlc ? " AIV" : "",
@@ -295,7 +295,7 @@ int ff_h263_decode_motion(H263DecContext *const h, int pred, int f_code) · 203 unmodified lines
295 val += pred;295 val += pred;
296 296
297 /* modulo decoding */297 /* modulo decoding */
298 if (!h->c.h263_long_vectors) {298 if (!h->h263_long_vectors) {
299 val = sign_extend(val, 5 + f_code);299 val = sign_extend(val, 5 + f_code);
300 } else {300 } else {
301 /* horrible H.263 long vector mode */301 /* horrible H.263 long vector mode */
@@ -545,10 +545,10 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64], · 243 unmodified lines
545 } else if (h->c.mb_intra) {545 } else if (h->c.mb_intra) {
546 /* DC coef */546 /* DC coef */
547 if (CONFIG_RV10_DECODER && h->c.codec_id == AV_CODEC_ID_RV10) {547 if (CONFIG_RV10_DECODER && h->c.codec_id == AV_CODEC_ID_RV10) {
548 if (h->c.rv10_version == 3 && h->c.pict_type == AV_PICTURE_TYPE_I) {548 if (h->rv10_version == 3 && h->c.pict_type == AV_PICTURE_TYPE_I) {
549 int component = (n <= 3 ? 0 : n - 4 + 1);549 int component = (n <= 3 ? 0 : n - 4 + 1);
550 level = h->c.last_dc[component];550 level = h->c.last_dc[component];
551 if (h->c.rv10_first_dc_coded[component]) {551 if (h->rv10_first_dc_coded[component]) {
552 int diff = ff_rv_decode_dc(h, n);552 int diff = ff_rv_decode_dc(h, n);
553 if (diff < 0)553 if (diff < 0)
554 return -1;554 return -1;
@@ -556,7 +556,7 @@ static int h263_decode_block(H263DecContext *const h, int16_t block[64], · 1 unmodified line
556 level = level & 0xff; /* handle wrap round */556 level = level & 0xff; /* handle wrap round */
557 h->c.last_dc[component] = level;557 h->c.last_dc[component] = level;
558 } else {558 } else {
559 h->c.rv10_first_dc_coded[component] = 1;559 h->rv10_first_dc_coded[component] = 1;
560 }560 }
561 } else {561 } else {
562 level = get_bits(&h->gb, 8);562 level = get_bits(&h->gb, 8);
@@ -816,8 +816,8 @@ int ff_h263_decode_mb(H263DecContext *const h) · 253 unmodified lines
816 if (h->c.mb_intra)816 if (h->c.mb_intra)
817 goto intra;817 goto intra;
818 818
819 if (h->c.pb_frame && get_bits1(&h->gb))819 if (h->pb_frame && get_bits1(&h->gb))
820 pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);820 pb_mv_count = h263_get_modb(&h->gb, h->pb_frame, &cbpb);
821 cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);821 cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
822 822
823 if (cbpy < 0) {823 if (cbpy < 0) {
@@ -1029,8 +1029,8 @@ intra: · 205 unmodified lines
1029 }else1029 }else
1030 h->c.ac_pred = 0;1030 h->c.ac_pred = 0;
1031 1031
1032 if (h->c.pb_frame && get_bits1(&h->gb))1032 if (h->pb_frame && get_bits1(&h->gb))
1033 pb_mv_count = h263_get_modb(&h->gb, h->c.pb_frame, &cbpb);1033 pb_mv_count = h263_get_modb(&h->gb, h->pb_frame, &cbpb);
1034 cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);1034 cbpy = get_vlc2(&h->gb, ff_h263_cbpy_vlc, CBPY_VLC_BITS, 1);
1035 if(cbpy<0){1035 if(cbpy<0){
1036 av_log(h->c.avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n",1036 av_log(h->c.avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n",
@@ -1042,7 +1042,7 @@ intra: · 5 unmodified lines
1042 h263_decode_dquant(h);1042 h263_decode_dquant(h);
1043 }1043 }
1044 1044
1045 pb_mv_count += !!h->c.pb_frame;1045 pb_mv_count += !!h->pb_frame;
1046 }1046 }
1047 1047
1048 while(pb_mv_count--){1048 while(pb_mv_count--){
@@ -1057,7 +1057,7 @@ intra: · 8 unmodified lines
1057 cbp+=cbp;1057 cbp+=cbp;
1058 }1058 }
1059 1059
1060 if (h->c.pb_frame && h263_skip_b_part(h, cbpb) < 0)1060 if (h->pb_frame && h263_skip_b_part(h, cbpb) < 0)
1061 return -1;1061 return -1;
1062 if (h->c.obmc && !h->c.mb_intra) {1062 if (h->c.obmc && !h->c.mb_intra) {
1063 if (h->c.pict_type == AV_PICTURE_TYPE_P &&1063 if (h->c.pict_type == AV_PICTURE_TYPE_P &&
@@ -1146,7 +1146,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 82 unmodified lines
1146 1146
1147 h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);1147 h->c.pict_type = AV_PICTURE_TYPE_I + get_bits1(&h->gb);
1148 1148
1149 h->c.h263_long_vectors = get_bits1(&h->gb);1149 h->h263_long_vectors = get_bits1(&h->gb);
1150 1150
1151 if (get_bits1(&h->gb) != 0) {1151 if (get_bits1(&h->gb) != 0) {
1152 av_log(h->c.avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");1152 av_log(h->c.avctx, AV_LOG_ERROR, "H.263 SAC not supported\n");
@@ -1154,7 +1154,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 1 unmodified line
1154 }1154 }
1155 h->c.obmc = get_bits1(&h->gb); /* Advanced prediction mode */1155 h->c.obmc = get_bits1(&h->gb); /* Advanced prediction mode */
1156 1156
1157 h->c.pb_frame = get_bits1(&h->gb);1157 h->pb_frame = get_bits1(&h->gb);
1158 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);1158 h->c.chroma_qscale = h->c.qscale = get_bits(&h->gb, 5);
1159 skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */1159 skip_bits1(&h->gb); /* Continuous Presence Multipoint mode: off */
1160 1160
@@ -1174,7 +1174,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 13 unmodified lines
1174 /* OPPTYPE */1174 /* OPPTYPE */
1175 format = get_bits(&h->gb, 3);1175 format = get_bits(&h->gb, 3);
1176 ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);1176 ff_dlog(h->c.avctx, "ufep=1, format: %d\n", format);
1177 h->c.custom_pcf = get_bits1(&h->gb);1177 h->custom_pcf = get_bits1(&h->gb);
1178 h->c.umvplus = get_bits1(&h->gb); /* Unrestricted Motion Vector */1178 h->c.umvplus = get_bits1(&h->gb); /* Unrestricted Motion Vector */
1179 if (get_bits1(&h->gb) != 0) {1179 if (get_bits1(&h->gb) != 0) {
1180 av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");1180 av_log(h->c.avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
@@ -1210,7 +1210,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 29 unmodified lines
1210 switch (h->c.pict_type) {1210 switch (h->c.pict_type) {
1211 case 0: h->c.pict_type = AV_PICTURE_TYPE_I; break;1211 case 0: h->c.pict_type = AV_PICTURE_TYPE_I; break;
1212 case 1: h->c.pict_type = AV_PICTURE_TYPE_P; break;1212 case 1: h->c.pict_type = AV_PICTURE_TYPE_P; break;
1213 case 2: h->c.pict_type = AV_PICTURE_TYPE_P; h->c.pb_frame = 3; break;1213 case 2: h->c.pict_type = AV_PICTURE_TYPE_P; h->pb_frame = 3; break;
1214 case 3: h->c.pict_type = AV_PICTURE_TYPE_B; break;1214 case 3: h->c.pict_type = AV_PICTURE_TYPE_B; break;
1215 case 7: h->c.pict_type = AV_PICTURE_TYPE_I; break; //ZYGO1215 case 7: h->c.pict_type = AV_PICTURE_TYPE_I; break; //ZYGO
1216 default:1216 default:
@@ -1251,13 +1251,13 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 34 unmodified lines
1251 height = ff_h263_format[format][1];1251 height = ff_h263_format[format][1];
1252 h->c.avctx->sample_aspect_ratio = (AVRational){12,11};1252 h->c.avctx->sample_aspect_ratio = (AVRational){12,11};
1253 }1253 }
1254 h->c.avctx->sample_aspect_ratio.den <<= h->c.ehc_mode;1254 h->c.avctx->sample_aspect_ratio.den <<= h->ehc_mode;
1255 if ((width == 0) || (height == 0))1255 if ((width == 0) || (height == 0))
1256 return -1;1256 return -1;
1257 h->c.width = width;1257 h->c.width = width;
1258 h->c.height = height;1258 h->c.height = height;
1259 1259
1260 if (h->c.custom_pcf) {1260 if (h->custom_pcf) {
1261 h->c.avctx->framerate.num = 1800000;1261 h->c.avctx->framerate.num = 1800000;
1262 h->c.avctx->framerate.den = 1000 + get_bits1(&h->gb);1262 h->c.avctx->framerate.den = 1000 + get_bits1(&h->gb);
1263 h->c.avctx->framerate.den *= get_bits(&h->gb, 7);1263 h->c.avctx->framerate.den *= get_bits(&h->gb, 7);
@@ -1273,7 +1273,7 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 9 unmodified lines
1273 }1273 }
1274 }1274 }
1275 1275
1276 if (h->c.custom_pcf)1276 if (h->custom_pcf)
1277 skip_bits(&h->gb, 2); //extended Temporal reference1277 skip_bits(&h->gb, 2); //extended Temporal reference
1278 1278
1279 if (ufep) {1279 if (ufep) {
@@ -1315,9 +1315,9 @@ int ff_h263_decode_picture_header(H263DecContext *const h) · 35 unmodified lines
1315 1315
1316 h->c.gob_index = H263_GOB_HEIGHT(h->c.height);1316 h->c.gob_index = H263_GOB_HEIGHT(h->c.height);
1317 1317
1318 if (h->c.pb_frame) {1318 if (h->pb_frame) {
1319 skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */1319 skip_bits(&h->gb, 3); /* Temporal reference for B-pictures */
1320 if (h->c.custom_pcf)1320 if (h->custom_pcf)
1321 skip_bits(&h->gb, 2); //extended Temporal reference1321 skip_bits(&h->gb, 2); //extended Temporal reference
1322 skip_bits(&h->gb, 2); /* Quantization information for B-pictures */1322 skip_bits(&h->gb, 2); /* Quantization information for B-pictures */
1323 }1323 }
libavcodec/mpeg4videodec.c+19−17
@@ -3031,7 +3031,7 @@ static int decode_user_data(Mpeg4DecContext *ctx, GetBitContext *gb) · 3030 unmodified lines
3031 if (e >= 2) {3031 if (e >= 2) {
3032 ctx->divx_version = ver;3032 ctx->divx_version = ver;
3033 ctx->divx_build = build;3033 ctx->divx_build = build;
3034 h->c.divx_packed = e == 3 && last == 'p';3034 h->divx_packed = e == 3 && last == 'p';
3035 }3035 }
3036 3036
3037 /* libavcodec detection */3037 /* libavcodec detection */
@@ -3132,7 +3132,7 @@ void ff_mpeg4_workaround_bugs(AVCodecContext *avctx) · 94 unmodified lines
3132 h->c.workaround_bugs |= FF_BUG_QPEL_CHROMA2;3132 h->c.workaround_bugs |= FF_BUG_QPEL_CHROMA2;
3133 3133
3134 if (ctx->xvid_build <= 3U)3134 if (ctx->xvid_build <= 3U)
3135 h->c.padding_bug_score = 256 * 256 * 256 * 64;3135 h->padding_bug_score = 256 * 256 * 256 * 64;
3136 3136
3137 if (ctx->xvid_build <= 1U)3137 if (ctx->xvid_build <= 1U)
3138 h->c.workaround_bugs |= FF_BUG_QPEL_CHROMA;3138 h->c.workaround_bugs |= FF_BUG_QPEL_CHROMA;
@@ -3170,7 +3170,7 @@ void ff_mpeg4_workaround_bugs(AVCodecContext *avctx) · 31 unmodified lines
3170 if (ctx->divx_version >= 0)3170 if (ctx->divx_version >= 0)
3171 h->c.workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;3171 h->c.workaround_bugs |= FF_BUG_DIRECT_BLOCKSIZE;
3172 if (ctx->divx_version == 501 && ctx->divx_build == 20020416)3172 if (ctx->divx_version == 501 && ctx->divx_build == 20020416)
3173 h->c.padding_bug_score = 256 * 256 * 256 * 64;3173 h->padding_bug_score = 256 * 256 * 256 * 64;
3174 3174
3175 if (ctx->divx_version < 500U)3175 if (ctx->divx_version < 500U)
3176 h->c.workaround_bugs |= FF_BUG_EDGE;3176 h->c.workaround_bugs |= FF_BUG_EDGE;
@@ -3199,7 +3199,7 @@ void ff_mpeg4_workaround_bugs(AVCodecContext *avctx) · 22 unmodified lines
3199 av_log(h->c.avctx, AV_LOG_DEBUG,3199 av_log(h->c.avctx, AV_LOG_DEBUG,
3200 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",3200 "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
3201 h->c.workaround_bugs, ctx->lavc_build, ctx->xvid_build,3201 h->c.workaround_bugs, ctx->lavc_build, ctx->xvid_build,
3202 ctx->divx_version, ctx->divx_build, h->c.divx_packed ? "p" : "");3202 ctx->divx_version, ctx->divx_build, h->divx_packed ? "p" : "");
3203 3203
3204 if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&3204 if (CONFIG_MPEG4_DECODER && ctx->xvid_build >= 0 &&
3205 avctx->idct_algo == FF_IDCT_AUTO && !h->c.studio_profile) {3205 avctx->idct_algo == FF_IDCT_AUTO && !h->c.studio_profile) {
@@ -3313,7 +3313,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, · 107 unmodified lines
3313 if (get_bits1(gb) != 1) {3313 if (get_bits1(gb) != 1) {
3314 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)3314 if (h->c.avctx->debug & FF_DEBUG_PICT_INFO)
3315 av_log(h->c.avctx, AV_LOG_ERROR, "vop not coded\n");3315 av_log(h->c.avctx, AV_LOG_ERROR, "vop not coded\n");
3316 h->c.skipped_last_frame = 1;3316 h->skipped_last_frame = 1;
3317 return FRAME_SKIPPED;3317 return FRAME_SKIPPED;
3318 }3318 }
3319 if (ctx->new_pred)3319 if (ctx->new_pred)
@@ -3740,14 +3740,14 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h) · 420 unmodified lines
3740{3740{
3741 Mpeg4DecContext *const ctx = h263_to_mpeg4(h);3741 Mpeg4DecContext *const ctx = h263_to_mpeg4(h);
3742 3742
3743 h->c.skipped_last_frame = 0;3743 h->skipped_last_frame = 0;
3744 3744
3745 if (ctx->bitstream_buffer) {3745 if (ctx->bitstream_buffer) {
3746 int buf_size = get_bits_left(&h->gb) / 8U;3746 int buf_size = get_bits_left(&h->gb) / 8U;
3747 int bitstream_buffer_size = ctx->bitstream_buffer->size;3747 int bitstream_buffer_size = ctx->bitstream_buffer->size;
3748 const uint8_t *buf = h->gb.buffer;3748 const uint8_t *buf = h->gb.buffer;
3749 3749
3750 if (h->c.divx_packed) {3750 if (h->divx_packed) {
3751 for (int i = 0; i < buf_size - 3; i++) {3751 for (int i = 0; i < buf_size - 3; i++) {
3752 if (buf[i] == 0 && buf[i+1] == 0 && buf[i+2] == 1) {3752 if (buf[i] == 0 && buf[i+1] == 0 && buf[i+2] == 1) {
3753 if (buf[i+3] == 0xB0) {3753 if (buf[i+3] == 0xB0) {
@@ -3759,7 +3759,7 @@ int ff_mpeg4_decode_picture_header(H263DecContext *const h) · 5 unmodified lines
3759 }3759 }
3760 }3760 }
3761 ctx->bitstream_buffer->size = 0;3761 ctx->bitstream_buffer->size = 0;
3762 if (bitstream_buffer_size && (h->c.divx_packed || buf_size <= MAX_NVOP_SIZE)) {// divx 5.01+/xvid frame reorder3762 if (bitstream_buffer_size && (h->divx_packed || buf_size <= MAX_NVOP_SIZE)) {// divx 5.01+/xvid frame reorder
3763 int ret = init_get_bits8(&h->gb, ctx->bitstream_buffer->data,3763 int ret = init_get_bits8(&h->gb, ctx->bitstream_buffer->data,
3764 bitstream_buffer_size);3764 bitstream_buffer_size);
3765 if (ret < 0)3765 if (ret < 0)
@@ -3780,7 +3780,7 @@ int ff_mpeg4_frame_end(AVCodecContext *avctx, const AVPacket *pkt) · 14 unmodified lines
3780 av_assert1(!ctx->bitstream_buffer || !ctx->bitstream_buffer->size);3780 av_assert1(!ctx->bitstream_buffer || !ctx->bitstream_buffer->size);
3781 3781
3782 /* divx 5.01+ bitstream reorder stuff */3782 /* divx 5.01+ bitstream reorder stuff */
3783 if (h->c.divx_packed) {3783 if (h->divx_packed) {
3784 int current_pos = ctx->bitstream_buffer && h->gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->gb) >> 3);3784 int current_pos = ctx->bitstream_buffer && h->gb.buffer == ctx->bitstream_buffer->data ? 0 : (get_bits_count(&h->gb) >> 3);
3785 int startcode_found = 0;3785 int startcode_found = 0;
3786 uint8_t *buf = pkt->data;3786 uint8_t *buf = pkt->data;
@@ -3907,7 +3907,7 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, · 120 unmodified lines
3907 s->enhancement_type = s1->enhancement_type;3907 s->enhancement_type = s1->enhancement_type;
3908 s->scalability = s1->scalability;3908 s->scalability = s1->scalability;
3909 s->intra_dc_threshold = s1->intra_dc_threshold;3909 s->intra_dc_threshold = s1->intra_dc_threshold;
3910 s->h.c.divx_packed = s1->h.c.divx_packed;3910 s->h.divx_packed = s1->h.divx_packed;
3911 s->divx_version = s1->divx_version;3911 s->divx_version = s1->divx_version;
3912 s->divx_build = s1->divx_build;3912 s->divx_build = s1->divx_build;
3913 s->xvid_build = s1->xvid_build;3913 s->xvid_build = s1->xvid_build;
@@ -3919,7 +3919,9 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, · 5 unmodified lines
3919 s->cplx_estimation_trash_p = s1->cplx_estimation_trash_p;3919 s->cplx_estimation_trash_p = s1->cplx_estimation_trash_p;
3920 s->cplx_estimation_trash_b = s1->cplx_estimation_trash_b;3920 s->cplx_estimation_trash_b = s1->cplx_estimation_trash_b;
3921 s->rgb = s1->rgb;3921 s->rgb = s1->rgb;
3922 s->h.c.skipped_last_frame = s1->h.c.skipped_last_frame;3922
3923 s->h.skipped_last_frame = s1->h.skipped_last_frame;
3924 s->h.padding_bug_score = s1->h.padding_bug_score; // FIXME: racy
3923 3925
3924 memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift));3926 memcpy(s->sprite_shift, s1->sprite_shift, sizeof(s1->sprite_shift));
3925 memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj));3927 memcpy(s->sprite_traj, s1->sprite_traj, sizeof(s1->sprite_traj));
@@ -3930,11 +3932,11 @@ static int mpeg4_update_thread_context(AVCodecContext *dst, · 4 unmodified lines
3930static int mpeg4_update_thread_context_for_user(AVCodecContext *dst,3932static int mpeg4_update_thread_context_for_user(AVCodecContext *dst,
3931 const AVCodecContext *src)3933 const AVCodecContext *src)
3932{3934{
3933 MpegEncContext *m = dst->priv_data;3935 H263DecContext *const h = dst->priv_data;
3934 const MpegEncContext *m1 = src->priv_data;3936 const H263DecContext *const h1 = src->priv_data;
3935 3937
3936 m->quarter_sample = m1->quarter_sample;3938 h->c.quarter_sample = h1->c.quarter_sample;
3937 m->divx_packed = m1->divx_packed;3939 h->divx_packed = h1->divx_packed;
3938 3940
3939 return 0;3941 return 0;
3940}3942}
@@ -4054,10 +4056,10 @@ static av_cold int mpeg4_close(AVCodecContext *avctx) · 113 unmodified lines
4054 return ff_mpv_decode_close(avctx);4056 return ff_mpv_decode_close(avctx);
4055}4057}
4056 4058
4057#define OFFSET(x) offsetof(MpegEncContext, x)4059#define OFFSET(x) offsetof(H263DecContext, x)
4058#define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY4060#define FLAGS AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY
4059static const AVOption mpeg4_options[] = {4061static const AVOption mpeg4_options[] = {
4060 {"quarter_sample", "1/4 subpel MC", OFFSET(quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},4062 {"quarter_sample", "1/4 subpel MC", OFFSET(c.quarter_sample), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
4061 {"divx_packed", "divx style packed b frames", OFFSET(divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},4063 {"divx_packed", "divx style packed b frames", OFFSET(divx_packed), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},
4062 {NULL}4064 {NULL}
4063};4065};
libavcodec/mpegvideo.h+0−15
@@ -86,7 +86,6 @@ typedef struct MpegEncContext { · 85 unmodified lines
86 int width, height;///< picture size. must be a multiple of 1686 int width, height;///< picture size. must be a multiple of 16
87 enum OutputFormat out_format; ///< output format87 enum OutputFormat out_format; ///< output format
88 int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions88 int h263_pred; ///< use MPEG-4/H.263 ac/dc predictions
89 int pb_frame; ///< PB-frame mode (0 = none, 1 = base, 2 = improved)
90 89
91/* the following codec id fields are deprecated in favor of codec_id */90/* the following codec id fields are deprecated in favor of codec_id */
92 int h263_flv; ///< use flv H.263 header91 int h263_flv; ///< use flv H.263 header
@@ -138,7 +137,6 @@ typedef struct MpegEncContext { · 45 unmodified lines
138 */137 */
139 MPVWorkPicture cur_pic;138 MPVWorkPicture cur_pic;
140 139
141 int skipped_last_frame;
142 int last_dc[3]; ///< last DC values for MPEG-1140 int last_dc[3]; ///< last DC values for MPEG-1
143 int16_t *dc_val_base;141 int16_t *dc_val_base;
144 const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table142 const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table
@@ -163,9 +161,6 @@ typedef struct MpegEncContext { · 18 unmodified lines
163 int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...161 int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
164 int droppable;162 int droppable;
165 163
166 /* motion compensation */
167 int h263_long_vectors; ///< use horrible H.263v1 long vector mode
168
169 BlockDSPContext bdsp;164 BlockDSPContext bdsp;
170 H264ChromaContext h264chroma;165 H264ChromaContext h264chroma;
171 HpelDSPContext hdsp;166 HpelDSPContext hdsp;
@@ -224,7 +219,6 @@ typedef struct MpegEncContext { · 52 unmodified lines
224 /* H.263 specific */219 /* H.263 specific */
225 int gob_index;220 int gob_index;
226 int obmc; ///< overlapped block motion compensation221 int obmc; ///< overlapped block motion compensation
227 int ehc_mode;
228 222
229 /* H.263+ specific */223 /* H.263+ specific */
230 int umvplus; ///< == H.263+ && unrestricted_mv224 int umvplus; ///< == H.263+ && unrestricted_mv
@@ -233,7 +227,6 @@ typedef struct MpegEncContext { · 2 unmodified lines
233 int alt_inter_vlc; ///< alternative inter vlc227 int alt_inter_vlc; ///< alternative inter vlc
234 int modified_quant;228 int modified_quant;
235 int loop_filter;229 int loop_filter;
236 int custom_pcf;
237 230
238 /* MPEG-4 specific */231 /* MPEG-4 specific */
239 int studio_profile;232 int studio_profile;
@@ -250,14 +243,6 @@ typedef struct MpegEncContext { · 10 unmodified lines
250 int data_partitioning; ///< data partitioning flag from header243 int data_partitioning; ///< data partitioning flag from header
251 int partitioned_frame; ///< is current frame partitioned244 int partitioned_frame; ///< is current frame partitioned
252 int low_delay; ///< no reordering needed / has no B-frames245 int low_delay; ///< no reordering needed / has no B-frames
253 int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG-4
254
255 /* divx specific, used to workaround (many) bugs in divx5 */
256 int divx_packed;
257
258 /* RV10 specific */
259 int rv10_version; ///< RV10 version: 0 or 3
260 int rv10_first_dc_coded[3];
261 246
262 /* MSMPEG4 specific */247 /* MSMPEG4 specific */
263 int slice_height; ///< in macroblocks248 int slice_height; ///< in macroblocks
libavcodec/mpegvideo_dec.c+0−1
@@ -108,7 +108,6 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, · 107 unmodified lines
108 108
109 // Error/bug resilience109 // Error/bug resilience
110 s->workaround_bugs = s1->workaround_bugs;110 s->workaround_bugs = s1->workaround_bugs;
111 s->padding_bug_score = s1->padding_bug_score;
112 111
113 // MPEG-4 timing info112 // MPEG-4 timing info
114 memcpy(&s->last_time_base, &s1->last_time_base,113 memcpy(&s->last_time_base, &s1->last_time_base,
libavcodec/nvdec_mpeg4.c+1−1
@@ -73,7 +73,7 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, · 72 unmodified lines
73 .quant_type = m->mpeg_quant,73 .quant_type = m->mpeg_quant,
74 .quarter_sample = s->quarter_sample,74 .quarter_sample = s->quarter_sample,
75 .short_video_header = avctx->codec->id == AV_CODEC_ID_H263,75 .short_video_header = avctx->codec->id == AV_CODEC_ID_H263,
76 .divx_flags = s->divx_packed ? 5 : 0,76 .divx_flags = m->h.divx_packed ? 5 : 0,
77 77
78 .vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I,78 .vop_coding_type = s->pict_type - AV_PICTURE_TYPE_I,
79 .vop_coded = 1,79 .vop_coded = 1,
libavcodec/rv10.c+6−6
@@ -127,7 +127,7 @@ static int rv10_decode_picture_header(H263DecContext *const h) · 126 unmodified lines
127 }127 }
128 128
129 if (h->c.pict_type == AV_PICTURE_TYPE_I) {129 if (h->c.pict_type == AV_PICTURE_TYPE_I) {
130 if (h->c.rv10_version == 3) {130 if (h->rv10_version == 3) {
131 /* specific MPEG like DC coding not used */131 /* specific MPEG like DC coding not used */
132 h->c.last_dc[0] = get_bits(&h->gb, 8);132 h->c.last_dc[0] = get_bits(&h->gb, 8);
133 h->c.last_dc[1] = get_bits(&h->gb, 8);133 h->c.last_dc[1] = get_bits(&h->gb, 8);
@@ -369,7 +369,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) · 235 unmodified lines
369 rv->orig_width = avctx->coded_width;369 rv->orig_width = avctx->coded_width;
370 rv->orig_height = avctx->coded_height;370 rv->orig_height = avctx->coded_height;
371 371
372 h->c.h263_long_vectors = avctx->extradata[3] & 1;372 h->h263_long_vectors = avctx->extradata[3] & 1;
373 rv->sub_id = AV_RB32A(avctx->extradata + 4);373 rv->sub_id = AV_RB32A(avctx->extradata + 4);
374 if (avctx->codec_id == AV_CODEC_ID_RV20) {374 if (avctx->codec_id == AV_CODEC_ID_RV20) {
375 h->c.modified_quant = 1;375 h->c.modified_quant = 1;
@@ -382,7 +382,7 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) · 6 unmodified lines
382 382
383 switch (major_ver) {383 switch (major_ver) {
384 case 1:384 case 1:
385 h->c.rv10_version = micro_ver ? 3 : 1;385 h->rv10_version = micro_ver ? 3 : 1;
386 h->c.obmc = micro_ver == 2;386 h->c.obmc = micro_ver == 2;
387 break;387 break;
388 case 2:388 case 2:
@@ -475,9 +475,9 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, · 86 unmodified lines
475 475
476 ff_set_qscale(&h->c, h->c.qscale);476 ff_set_qscale(&h->c, h->c.qscale);
477 477
478 h->c.rv10_first_dc_coded[0] = 0;478 h->rv10_first_dc_coded[0] = 0;
479 h->c.rv10_first_dc_coded[1] = 0;479 h->rv10_first_dc_coded[1] = 0;
480 h->c.rv10_first_dc_coded[2] = 0;480 h->rv10_first_dc_coded[2] = 0;
481 ff_init_block_index(&h->c);481 ff_init_block_index(&h->c);
482 482
483 /* decode each macroblock */483 /* decode each macroblock */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t