History

avcodec/mpegvideo: Move partitioned_frame to {H263Dec,MPVEnc}Context

Andreas Rheinhardt committed 1 year ago

Commit 60f51bd1 parent 09847247 files · +21 −20Browse files

Unified · Split

7 files
  1. libavcodec/h263dec.c +8 −8
  2. libavcodec/h263dec.h +1 −0
  3. libavcodec/mpeg4videodec.c +5 −5
  4. libavcodec/mpeg4videoenc.c +1 −1
  5. libavcodec/mpegvideo.h +0 −1
  6. libavcodec/mpegvideo_enc.c +5 −5
  7. libavcodec/mpegvideoenc.h +1 −0
libavcodec/h263dec.c+8−8
@@ -181,15 +181,15 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) · 180 unmodified lines
181 return 0;181 return 0;
182}182}
183 183
184static void report_decode_progress(MpegEncContext *s)184static void report_decode_progress(H263DecContext *const h)
185{185{
186 if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred)186 if (h->c.pict_type != AV_PICTURE_TYPE_B && !h->partitioned_frame && !h->c.er.error_occurred)
187 ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y);187 ff_thread_progress_report(&h->c.cur_pic.ptr->progress, h->c.mb_y);
188}188}
189 189
190static int decode_slice(H263DecContext *const h)190static int decode_slice(H263DecContext *const h)
191{191{
192 const int part_mask = h->c.partitioned_frame192 const int part_mask = h->partitioned_frame
193 ? (ER_AC_END | ER_AC_ERROR) : 0x7F;193 ? (ER_AC_END | ER_AC_ERROR) : 0x7F;
194 const int mb_size = 16 >> h->c.avctx->lowres;194 const int mb_size = 16 >> h->c.avctx->lowres;
195 int ret;195 int ret;
@@ -214,7 +214,7 @@ static int decode_slice(H263DecContext *const h) · 18 unmodified lines
214 return ret;214 return ret;
215 }215 }
216 216
217 if (h->c.partitioned_frame) {217 if (h->partitioned_frame) {
218 const int qscale = h->c.qscale;218 const int qscale = h->c.qscale;
219 219
220 if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)220 if (CONFIG_MPEG4_DECODER && h->c.codec_id == AV_CODEC_ID_MPEG4)
@@ -290,7 +290,7 @@ static int decode_slice(H263DecContext *const h) · 69 unmodified lines
290 290
291 if (++h->c.mb_x >= h->c.mb_width) {291 if (++h->c.mb_x >= h->c.mb_width) {
292 h->c.mb_x = 0;292 h->c.mb_x = 0;
293 report_decode_progress(&h->c);293 report_decode_progress(h);
294 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);294 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
295 h->c.mb_y++;295 h->c.mb_y++;
296 }296 }
@@ -317,7 +317,7 @@ static int decode_slice(H263DecContext *const h) · 20 unmodified lines
317 ff_h263_loop_filter(&h->c);317 ff_h263_loop_filter(&h->c);
318 }318 }
319 319
320 report_decode_progress(&h->c);320 report_decode_progress(h);
321 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);321 ff_mpeg_draw_horiz_band(&h->c, h->c.mb_y * mb_size, mb_size);
322 322
323 h->c.mb_x = 0;323 h->c.mb_x = 0;
@@ -551,7 +551,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 227 unmodified lines
551 return ret;551 return ret;
552 }552 }
553 553
554 ff_mpv_er_frame_start_ext(s, s->partitioned_frame,554 ff_mpv_er_frame_start_ext(s, h->partitioned_frame,
555 s->pp_time, s->pb_time);555 s->pp_time, s->pb_time);
556 556
557 /* the second part of the wmv2 header contains the MB skip bits which557 /* the second part of the wmv2 header contains the MB skip bits which
libavcodec/h263dec.h+1−0
@@ -73,6 +73,7 @@ typedef struct H263DecContext { · 72 unmodified lines
73 int skipped_last_frame;73 int skipped_last_frame;
74 int divx_packed; ///< divx specific, used to workaround (many) bugs in divx574 int divx_packed; ///< divx specific, used to workaround (many) bugs in divx5
75 int data_partitioning; ///< data partitioning flag from header75 int data_partitioning; ///< data partitioning flag from header
76 int partitioned_frame; ///< is current frame partitioned
76 77
77 /* MSMPEG4 specific */78 /* MSMPEG4 specific */
78 int slice_height; ///< in macroblocks79 int slice_height; ///< in macroblocks
libavcodec/mpeg4videodec.c+5−5
@@ -391,7 +391,7 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) · 390 unmodified lines
391 391
392 while (v <= 0xFF) {392 while (v <= 0xFF) {
393 if (h->c.pict_type == AV_PICTURE_TYPE_B ||393 if (h->c.pict_type == AV_PICTURE_TYPE_B ||
394 (v >> (8 - h->c.pict_type) != 1) || h->c.partitioned_frame)394 (v >> (8 - h->c.pict_type) != 1) || h->partitioned_frame)
395 break;395 break;
396 skip_bits(&h->gb, 8 + h->c.pict_type);396 skip_bits(&h->gb, 8 + h->c.pict_type);
397 bits_count += 8 + h->c.pict_type;397 bits_count += 8 + h->c.pict_type;
@@ -1395,7 +1395,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 997 unmodified lines
1395 // FIXME add short header support1395 // FIXME add short header support
1396 if (use_intra_dc_vlc) {1396 if (use_intra_dc_vlc) {
1397 /* DC coef */1397 /* DC coef */
1398 if (h->c.partitioned_frame) {1398 if (h->partitioned_frame) {
1399 level = h->c.dc_val[h->c.block_index[n]];1399 level = h->c.dc_val[h->c.block_index[n]];
1400 if (n < 4)1400 if (n < 4)
1401 level = FASTDIV((level + (h->c.y_dc_scale >> 1)), h->c.y_dc_scale);1401 level = FASTDIV((level + (h->c.y_dc_scale >> 1)), h->c.y_dc_scale);
@@ -3222,8 +3222,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, · 1820 unmodified lines
3222 h->c.low_delay = 0;3222 h->c.low_delay = 0;
3223 }3223 }
3224 3224
3225 h->c.partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;3225 h->partitioned_frame = h->data_partitioning && h->c.pict_type != AV_PICTURE_TYPE_B;
3226 if (h->c.partitioned_frame)3226 if (h->partitioned_frame)
3227 h->decode_mb = mpeg4_decode_partitioned_mb;3227 h->decode_mb = mpeg4_decode_partitioned_mb;
3228 else3228 else
3229 h->decode_mb = mpeg4_decode_mb;3229 h->decode_mb = mpeg4_decode_mb;
@@ -3513,7 +3513,7 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) · 283 unmodified lines
3513 if (get_bits_left(gb) <= 32)3513 if (get_bits_left(gb) <= 32)
3514 return 0;3514 return 0;
3515 3515
3516 h->c.partitioned_frame = 0;3516 h->partitioned_frame = 0;
3517 h->c.interlaced_dct = 0;3517 h->c.interlaced_dct = 0;
3518 h->decode_mb = mpeg4_decode_studio_mb;3518 h->decode_mb = mpeg4_decode_studio_mb;
3519 3519
libavcodec/mpeg4videoenc.c+1−1
@@ -1033,7 +1033,7 @@ static int mpeg4_encode_picture_header(MPVMainEncContext *const m) · 1032 unmodified lines
1033 mpeg4_encode_gop_header(m);1033 mpeg4_encode_gop_header(m);
1034 }1034 }
1035 1035
1036 s->c.partitioned_frame = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;1036 s->partitioned_frame = s->data_partitioning && s->c.pict_type != AV_PICTURE_TYPE_B;
1037 1037
1038 put_bits32(&s->pb, VOP_STARTCODE); /* vop header */1038 put_bits32(&s->pb, VOP_STARTCODE); /* vop header */
1039 put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */1039 put_bits(&s->pb, 2, s->c.pict_type - 1); /* pict type: I = 0 , P = 1 */
libavcodec/mpegvideo.h+0−1
@@ -229,7 +229,6 @@ typedef struct MpegEncContext { · 228 unmodified lines
229 uint16_t pb_field_time; ///< like above, just for interlaced229 uint16_t pb_field_time; ///< like above, just for interlaced
230 int mcsel;230 int mcsel;
231 int quarter_sample; ///< 1->qpel, 0->half pel ME/MC231 int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
232 int partitioned_frame; ///< is current frame partitioned
233 int low_delay; ///< no reordering needed / has no B-frames232 int low_delay; ///< no reordering needed / has no B-frames
234 233
235 /* MSMPEG4 specific */234 /* MSMPEG4 specific */
libavcodec/mpegvideo_enc.c+5−5
@@ -265,7 +265,7 @@ static void update_duplicate_context_after_me(MPVEncContext *const dst, · 264 unmodified lines
265 COPY(lambda2);265 COPY(lambda2);
266 COPY(c.frame_pred_frame_dct); // FIXME don't set in encode_header266 COPY(c.frame_pred_frame_dct); // FIXME don't set in encode_header
267 COPY(c.progressive_frame); // FIXME don't set in encode_header267 COPY(c.progressive_frame); // FIXME don't set in encode_header
268 COPY(c.partitioned_frame); // FIXME don't set in encode_header268 COPY(partitioned_frame); // FIXME don't set in encode_header
269#undef COPY269#undef COPY
270}270}
271 271
@@ -2894,7 +2894,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){ · 2622 unmodified lines
2894static void write_slice_end(MPVEncContext *const s)2894static void write_slice_end(MPVEncContext *const s)
2895{2895{
2896 if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4) {2896 if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4) {
2897 if (s->c.partitioned_frame)2897 if (s->partitioned_frame)
2898 ff_mpeg4_merge_partitions(s);2898 ff_mpeg4_merge_partitions(s);
2899 2899
2900 ff_mpeg4_stuffing(&s->pb);2900 ff_mpeg4_stuffing(&s->pb);
@@ -2907,7 +2907,7 @@ static void write_slice_end(MPVEncContext *const s) · 6 unmodified lines
2907 2907
2908 flush_put_bits(&s->pb);2908 flush_put_bits(&s->pb);
2909 2909
2910 if ((s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->c.partitioned_frame)2910 if ((s->c.avctx->flags & AV_CODEC_FLAG_PASS1) && !s->partitioned_frame)
2911 s->misc_bits+= get_bits_diff(s);2911 s->misc_bits+= get_bits_diff(s);
2912}2912}
2913 2913
@@ -3024,7 +3024,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 110 unmodified lines
3024 s->c.last_dc[1] = 128 * 8 / 14;3024 s->c.last_dc[1] = 128 * 8 / 14;
3025 s->c.last_dc[2] = 128 * 8 / 14;3025 s->c.last_dc[2] = 128 * 8 / 14;
3026#if CONFIG_MPEG4_ENCODER3026#if CONFIG_MPEG4_ENCODER
3027 } else if (s->c.partitioned_frame) {3027 } else if (s->partitioned_frame) {
3028 av_assert1(s->c.codec_id == AV_CODEC_ID_MPEG4);3028 av_assert1(s->c.codec_id == AV_CODEC_ID_MPEG4);
3029 ff_mpeg4_init_partitions(s);3029 ff_mpeg4_init_partitions(s);
3030#endif3030#endif
@@ -3120,7 +3120,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ · 89 unmodified lines
3120 if (s->c.start_mb_y != mb_y || mb_x != 0) {3120 if (s->c.start_mb_y != mb_y || mb_x != 0) {
3121 write_slice_end(s);3121 write_slice_end(s);
3122 3122
3123 if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && s->c.partitioned_frame)3123 if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && s->partitioned_frame)
3124 ff_mpeg4_init_partitions(s);3124 ff_mpeg4_init_partitions(s);
3125 }3125 }
3126 3126
libavcodec/mpegvideoenc.h+1−0
@@ -162,6 +162,7 @@ typedef struct MPVEncContext { · 161 unmodified lines
162 162
163 /* MPEG-4 specific */163 /* MPEG-4 specific */
164 int data_partitioning; ///< data partitioning flag, set via option164 int data_partitioning; ///< data partitioning flag, set via option
165 int partitioned_frame; ///< is current frame partitioned
165 int mpeg_quant;166 int mpeg_quant;
166 PutBitContext tex_pb; ///< used for data partitioned VOPs167 PutBitContext tex_pb; ///< used for data partitioned VOPs
167 PutBitContext pb2; ///< used for data partitioned VOPs168 PutBitContext pb2; ///< used for data partitioned VOPs

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