Commit f6774f90 authored by wm4's avatar wm4 Committed by Vittorio Giovara

mpegvideo: operate with pointers to AVFrames instead of whole structs

The most interesting parts are initialization in ff_MPV_common_init() and
uninitialization in ff_MPV_common_end().

ff_mpeg_unref_picture and ff_thread_release_buffer have additional NULL
checks for Picture.f, because these functions can be called on
uninitialized or partially initialized Pictures.

NULL pointer checks are added to ff_thread_release_buffer() stub function.
Signed-off-by: default avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 60fd7d36
......@@ -44,14 +44,14 @@ static void fill_picture_parameters(AVCodecContext *avctx,
int is_field = s->picture_structure != PICT_FRAME;
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(ctx, &current_picture->f);
pp->wDecodedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture->f);
pp->wDeblockedPictureIndex = 0;
if (s->pict_type != AV_PICTURE_TYPE_I)
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B)
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
pp->wPicWidthInMBminus1 = s->mb_width - 1;
......@@ -259,7 +259,7 @@ static int dxva2_mpeg2_end_frame(AVCodecContext *avctx)
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
ret = ff_dxva2_common_end_frame(avctx, &s->current_picture_ptr->f,
ret = ff_dxva2_common_end_frame(avctx, s->current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
......
......@@ -42,13 +42,13 @@ static void fill_picture_parameters(AVCodecContext *avctx,
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex =
pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, &current_picture->f);
pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture->f);
if (s->pict_type != AV_PICTURE_TYPE_I && !v->bi_type)
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture.f);
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->last_picture.f);
else
pp->wForwardRefPictureIndex = 0xffff;
if (s->pict_type == AV_PICTURE_TYPE_B && !v->bi_type)
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture.f);
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, s->next_picture.f);
else
pp->wBackwardRefPictureIndex = 0xffff;
if (v->profile == PROFILE_ADVANCED) {
......@@ -261,7 +261,7 @@ static int dxva2_vc1_end_frame(AVCodecContext *avctx)
if (ctx_pic->bitstream_size <= 0)
return -1;
ret = ff_dxva2_common_end_frame(avctx, &v->s.current_picture_ptr->f,
ret = ff_dxva2_common_end_frame(avctx, v->s.current_picture_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
NULL, 0,
commit_bitstream_and_slice_buffer);
......
......@@ -608,8 +608,8 @@ retry:
}
// for skipping the frame
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
s->current_picture.f->pict_type = s->pict_type;
s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
......@@ -632,10 +632,10 @@ retry:
}
ff_MPV_frame_end(s);
assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type);
assert(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
assert(s->current_picture.f->pict_type == s->pict_type);
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr);
......
......@@ -374,7 +374,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay == 0 && s->next_picture_ptr) {
if ((ret = av_frame_ref(pict, &s->next_picture_ptr->f)) < 0)
if ((ret = av_frame_ref(pict, s->next_picture_ptr->f)) < 0)
return ret;
s->next_picture_ptr = NULL;
......@@ -419,7 +419,7 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
if (s->current_picture_ptr == NULL || s->current_picture_ptr->f->data[0]) {
int i = ff_find_unused_picture(s, 0);
if (i < 0)
return i;
......@@ -506,8 +506,8 @@ int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->gob_index = ff_h263_get_gob_height(s);
// for skipping the frame
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
s->current_picture.f->pict_type = s->pict_type;
s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
/* skip B-frames if we don't have reference frames */
if (s->last_picture_ptr == NULL &&
......@@ -611,15 +611,15 @@ intrax8_decoded:
if (!s->divx_packed && avctx->hwaccel)
ff_thread_finish_setup(avctx);
assert(s->current_picture.f.pict_type ==
s->current_picture_ptr->f.pict_type);
assert(s->current_picture.f.pict_type == s->pict_type);
assert(s->current_picture.f->pict_type ==
s->current_picture_ptr->f->pict_type);
assert(s->current_picture.f->pict_type == s->pict_type);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr);
} else if (s->last_picture_ptr != NULL) {
if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr);
}
......
......@@ -306,7 +306,7 @@ static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma
int quant;
w->dsp.setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer,
s->current_picture.f.linesize[chroma>0],
s->current_picture.f->linesize[chroma>0],
&range, &sum, w->edges);
if(chroma){
w->orient=w->chroma_orient;
......@@ -615,7 +615,7 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
dc_level+= (w->predicted_dc*divide_quant + (1<<12) )>>13;
dsp_x8_put_solidcolor( av_clip_uint8((dc_level*dc_quant+4)>>3),
s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
s->dest[chroma], s->current_picture.f->linesize[!!chroma]);
goto block_placed;
}
......@@ -639,15 +639,15 @@ static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
}
if(w->flat_dc){
dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f.linesize[!!chroma]);
dsp_x8_put_solidcolor(w->predicted_dc, s->dest[chroma], s->current_picture.f->linesize[!!chroma]);
}else{
w->dsp.spatial_compensation[w->orient]( s->edge_emu_buffer,
s->dest[chroma],
s->current_picture.f.linesize[!!chroma] );
s->current_picture.f->linesize[!!chroma] );
}
if(!zeros_only)
s->dsp.idct_add ( s->dest[chroma],
s->current_picture.f.linesize[!!chroma],
s->current_picture.f->linesize[!!chroma],
s->block[0] );
block_placed:
......@@ -658,7 +658,7 @@ block_placed:
if(s->loop_filter){
uint8_t* ptr = s->dest[chroma];
int linesize = s->current_picture.f.linesize[!!chroma];
int linesize = s->current_picture.f->linesize[!!chroma];
if(!( (w->edges&2) || ( zeros_only && (w->orient|4)==4 ) )){
w->dsp.h_loop_filter(ptr, linesize, w->quant);
......@@ -673,12 +673,12 @@ block_placed:
static void x8_init_block_index(MpegEncContext *s){ //FIXME maybe merge with ff_*
//not s->linesize as this would be wrong for field pics
//not that IntraX8 has interlacing support ;)
const int linesize = s->current_picture.f.linesize[0];
const int uvlinesize = s->current_picture.f.linesize[1];
const int linesize = s->current_picture.f->linesize[0];
const int uvlinesize = s->current_picture.f->linesize[1];
s->dest[0] = s->current_picture.f.data[0];
s->dest[1] = s->current_picture.f.data[1];
s->dest[2] = s->current_picture.f.data[2];
s->dest[0] = s->current_picture.f->data[0];
s->dest[1] = s->current_picture.f->data[1];
s->dest[2] = s->current_picture.f->data[2];
s->dest[0] += s->mb_y * linesize << 3;
s->dest[1] += ( s->mb_y&(~1) ) * uvlinesize << 2;//chroma blocks are on add rows
......
......@@ -656,7 +656,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
return INT_MAX;
if(s->dsp.me_sub_cmp[0] != s->dsp.mb_cmp[0]){
dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f.data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
dmin_sum += s->dsp.mb_cmp[0](s, s->new_picture.f->data[0] + s->mb_x*16 + s->mb_y*16*stride, c->scratchpad, stride, 16);
}
if(c->avctx->mb_cmp&FF_CMP_CHROMA){
......@@ -671,15 +671,15 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
offset= (s->mb_x*8 + (mx>>1)) + (s->mb_y*8 + (my>>1))*s->uvlinesize;
if(s->no_rounding){
s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad , s->last_picture.f->data[1] + offset, s->uvlinesize, 8);
s->hdsp.put_no_rnd_pixels_tab[1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8);
}else{
s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.f.data[1] + offset, s->uvlinesize, 8);
s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f.data[2] + offset, s->uvlinesize, 8);
s->hdsp.put_pixels_tab [1][dxy](c->scratchpad , s->last_picture.f->data[1] + offset, s->uvlinesize, 8);
s->hdsp.put_pixels_tab [1][dxy](c->scratchpad + 8, s->last_picture.f->data[2] + offset, s->uvlinesize, 8);
}
dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8);
dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f.data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[1] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad , s->uvlinesize, 8);
dmin_sum += s->dsp.mb_cmp[1](s, s->new_picture.f->data[2] + s->mb_x*8 + s->mb_y*8*s->uvlinesize, c->scratchpad+8, s->uvlinesize, 8);
}
c->pred_x= mx;
......@@ -863,7 +863,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_type=0;
Picture * const pic= &s->current_picture;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0);
assert(s->quarter_sample==0 || s->quarter_sample==1);
assert(s->linesize == c->stride);
......@@ -1062,7 +1062,7 @@ int ff_pre_estimate_p_frame_motion(MpegEncContext * s,
int P[10][2];
const int shift= 1+s->quarter_sample;
const int xy= mb_x + mb_y*s->mb_stride;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data, NULL, 16*mb_x, 16*mb_y, 0);
init_ref(c, s->new_picture.f->data, s->last_picture.f->data, NULL, 16*mb_x, 16*mb_y, 0);
assert(s->quarter_sample==0 || s->quarter_sample==1);
......@@ -1501,8 +1501,8 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
int fmin, bmin, dmin, fbmin, bimin, fimin;
int type=0;
const int xy = mb_y*s->mb_stride + mb_x;
init_ref(c, s->new_picture.f.data, s->last_picture.f.data,
s->next_picture.f.data, 16 * mb_x, 16 * mb_y, 2);
init_ref(c, s->new_picture.f->data, s->last_picture.f->data,
s->next_picture.f->data, 16 * mb_x, 16 * mb_y, 2);
get_limits(s, 16*mb_x, 16*mb_y);
......
......@@ -1354,8 +1354,8 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf,
s->mpeg_f_code[1][0] = f_code;
s->mpeg_f_code[1][1] = f_code;
}
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
s->current_picture.f->pict_type = s->pict_type;
s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
if (avctx->debug & FF_DEBUG_PICT_INFO)
av_log(avctx, AV_LOG_DEBUG,
......@@ -1517,8 +1517,8 @@ static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1)
s->pict_type = AV_PICTURE_TYPE_P;
} else
s->pict_type = AV_PICTURE_TYPE_B;
s->current_picture.f.pict_type = s->pict_type;
s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I;
s->current_picture.f->pict_type = s->pict_type;
s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
}
s->intra_dc_precision = get_bits(&s->gb, 2);
s->picture_structure = get_bits(&s->gb, 2);
......@@ -1593,19 +1593,19 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
ff_mpeg_er_frame_start(s);
/* first check if we must repeat the frame */
s->current_picture_ptr->f.repeat_pict = 0;
s->current_picture_ptr->f->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
s->current_picture_ptr->f.repeat_pict = 4;
s->current_picture_ptr->f->repeat_pict = 4;
else
s->current_picture_ptr->f.repeat_pict = 2;
s->current_picture_ptr->f->repeat_pict = 2;
} else if (s->progressive_frame) {
s->current_picture_ptr->f.repeat_pict = 1;
s->current_picture_ptr->f->repeat_pict = 1;
}
}
pan_scan = av_frame_new_side_data(&s->current_picture_ptr->f,
pan_scan = av_frame_new_side_data(s->current_picture_ptr->f,
AV_FRAME_DATA_PANSCAN,
sizeof(s1->pan_scan));
if (!pan_scan)
......@@ -1614,7 +1614,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
if (s1->a53_caption) {
AVFrameSideData *sd = av_frame_new_side_data(
&s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
s1->a53_caption_size);
if (sd)
memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
......@@ -1622,7 +1622,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
}
if (s1->has_stereo3d) {
AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);
AVStereo3D *stereo = av_stereo3d_create_side_data(s->current_picture_ptr->f);
if (!stereo)
return AVERROR(ENOMEM);
......@@ -1647,10 +1647,10 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
}
for (i = 0; i < 4; i++) {
s->current_picture.f.data[i] = s->current_picture_ptr->f.data[i];
s->current_picture.f->data[i] = s->current_picture_ptr->f->data[i];
if (s->picture_structure == PICT_BOTTOM_FIELD)
s->current_picture.f.data[i] +=
s->current_picture_ptr->f.linesize[i];
s->current_picture.f->data[i] +=
s->current_picture_ptr->f->linesize[i];
}
}
......@@ -2004,7 +2004,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_MPV_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
int ret = av_frame_ref(pict, &s->current_picture_ptr->f);
int ret = av_frame_ref(pict, s->current_picture_ptr->f);
if (ret < 0)
return ret;
ff_print_debug_info(s, s->current_picture_ptr);
......@@ -2014,7 +2014,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* latency of 1 frame for I- and P-frames */
/* XXX: use another variable than picture_number */
if (s->last_picture_ptr != NULL) {
int ret = av_frame_ref(pict, &s->last_picture_ptr->f);
int ret = av_frame_ref(pict, s->last_picture_ptr->f);
if (ret < 0)
return ret;
ff_print_debug_info(s, s->last_picture_ptr);
......@@ -2581,7 +2581,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, void *data,
if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
/* special case for last picture */
if (s2->low_delay == 0 && s2->next_picture_ptr) {
int ret = av_frame_ref(picture, &s2->next_picture_ptr->f);
int ret = av_frame_ref(picture, s2->next_picture_ptr->f);
if (ret < 0)
return ret;
......
......@@ -203,7 +203,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
if (aspect_ratio == 0.0)
aspect_ratio = 1.0; // pixel aspect 1.1 (VGA)
if (s->current_picture.f.key_frame) {
if (s->current_picture.f->key_frame) {
AVRational framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
/* mpeg1 header repeated every gop */
......@@ -293,10 +293,10 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
/* time code: we must convert from the real frame rate to a
* fake MPEG frame rate in case of low frame rate */
fps = (framerate.num + framerate.den / 2) / framerate.den;
time_code = s->current_picture_ptr->f.coded_picture_number +
time_code = s->current_picture_ptr->f->coded_picture_number +
s->avctx->timecode_frame_start;
s->gop_picture_number = s->current_picture_ptr->f.coded_picture_number;
s->gop_picture_number = s->current_picture_ptr->f->coded_picture_number;
if (s->drop_frame_timecode) {
/* only works for NTSC 29.97 */
int d = time_code / 17982;
......@@ -412,7 +412,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
if (s->progressive_sequence)
put_bits(&s->pb, 1, 0); /* no repeat */
else
put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
/* XXX: optimize the generation of this flag with entropy measures */
s->frame_pred_frame_dct = s->progressive_sequence;
......@@ -436,7 +436,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
for (i = 0; i < sizeof(svcd_scan_offset_placeholder); i++)
put_bits(&s->pb, 8, svcd_scan_offset_placeholder[i]);
}
side_data = av_frame_get_side_data(&s->current_picture_ptr->f,
side_data = av_frame_get_side_data(s->current_picture_ptr->f,
AV_FRAME_DATA_STEREO3D);
if (side_data) {
AVStereo3D *stereo = (AVStereo3D *)side_data->data;
......
......@@ -675,7 +675,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
y = s->height - 16;
offset = x + y * s->linesize;
p_pic = s->new_picture.f.data[0] + offset;
p_pic = s->new_picture.f->data[0] + offset;
s->mb_skipped = 1;
for (i = 0; i < s->max_b_frames; i++) {
......@@ -683,10 +683,10 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
int diff;
Picture *pic = s->reordered_input_picture[i + 1];
if (!pic || pic->f.pict_type != AV_PICTURE_TYPE_B)
if (!pic || pic->f->pict_type != AV_PICTURE_TYPE_B)
break;
b_pic = pic->f.data[0] + offset;
b_pic = pic->f->data[0] + offset;
if (!pic->shared)
b_pic += INPLACE_OFFSET;
diff = s->dsp.sad[0](NULL, p_pic, b_pic, s->linesize, 16);
......@@ -906,9 +906,9 @@ static void mpeg4_encode_gop_header(MpegEncContext *s)
put_bits(&s->pb, 16, 0);
put_bits(&s->pb, 16, GOP_STARTCODE);
time = s->current_picture_ptr->f.pts;
time = s->current_picture_ptr->f->pts;
if (s->reordered_input_picture[1])
time = FFMIN(time, s->reordered_input_picture[1]->f.pts);
time = FFMIN(time, s->reordered_input_picture[1]->f->pts);
time = time * s->avctx->time_base.num;
seconds = time / s->avctx->time_base.den;
......@@ -1118,7 +1118,7 @@ void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
}
put_bits(&s->pb, 3, 0); /* intra dc VLC threshold */
if (!s->progressive_sequence) {
put_bits(&s->pb, 1, s->current_picture_ptr->f.top_field_first);
put_bits(&s->pb, 1, s->current_picture_ptr->f->top_field_first);
put_bits(&s->pb, 1, s->alternate_scan);
}
// FIXME sprite stuff
......
This diff is collapsed.
......@@ -91,7 +91,7 @@ struct MpegEncContext;
* Picture.
*/
typedef struct Picture{
struct AVFrame f;
struct AVFrame *f;
ThreadFrame tf;
AVBufferRef *qscale_table_buf;
......
This diff is collapsed.
......@@ -254,8 +254,8 @@ void mpeg_motion_internal(MpegEncContext *s,
#endif
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->current_picture.f.linesize[0] << field_based;
uvlinesize = s->current_picture.f.linesize[1] << field_based;
linesize = s->current_picture.f->linesize[0] << field_based;
uvlinesize = s->current_picture.f->linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
......@@ -900,7 +900,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
} else {
if (s->picture_structure != s->field_select[dir][0] + 1 &&
s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
ref_picture = s->current_picture_ptr->f->data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
......@@ -917,7 +917,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
|| s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
ref2picture = ref_picture;
} else {
ref2picture = s->current_picture_ptr->f.data;
ref2picture = s->current_picture_ptr->f->data;
}
mpeg_motion(s, dest_y, dest_cb, dest_cr,
......@@ -956,7 +956,7 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
/* opposite parity is always in the same frame if this is
* second field */
if (!s->first_field) {
ref_picture = s->current_picture_ptr->f.data;
ref_picture = s->current_picture_ptr->f->data;
}
}
}
......
......@@ -44,7 +44,7 @@
*/
void ff_xvmc_init_block(MpegEncContext *s)
{
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render && render->xvmc_id == AV_XVMC_ID);
s->block = (int16_t (*)[64])(render->data_blocks + render->next_free_data_block_num * 64);
......@@ -76,7 +76,7 @@ void ff_xvmc_pack_pblocks(MpegEncContext *s, int cbp)
*/
int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
{
struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
struct xvmc_pix_fmt *last, *next, *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
const int mb_block_count = 4 + (1 << s->chroma_format);
assert(avctx);
......@@ -116,7 +116,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
case AV_PICTURE_TYPE_I:
return 0; // no prediction from other frames
case AV_PICTURE_TYPE_B:
next = (struct xvmc_pix_fmt*)s->next_picture.f.data[2];
next = (struct xvmc_pix_fmt*)s->next_picture.f->data[2];
if (!next)
return -1;
if (next->xvmc_id != AV_XVMC_ID)
......@@ -124,7 +124,7 @@ int ff_xvmc_field_start(MpegEncContext *s, AVCodecContext *avctx)
render->p_future_surface = next->p_surface;
// no return here, going to set forward prediction
case AV_PICTURE_TYPE_P:
last = (struct xvmc_pix_fmt*)s->last_picture.f.data[2];
last = (struct xvmc_pix_fmt*)s->last_picture.f->data[2];
if (!last)
last = render; // predict second field from the first
if (last->xvmc_id != AV_XVMC_ID)
......@@ -144,7 +144,7 @@ return -1;
*/
void ff_xvmc_field_end(MpegEncContext *s)
{
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
struct xvmc_pix_fmt *render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
if (render->filled_mv_blocks_num > 0)
......@@ -185,7 +185,7 @@ void ff_xvmc_decode_mb(MpegEncContext *s)
s->current_picture.qscale_table[mb_xy] = s->qscale;
// start of XVMC-specific code
render = (struct xvmc_pix_fmt*)s->current_picture.f.data[2];
render = (struct xvmc_pix_fmt*)s->current_picture.f->data[2];
assert(render);
assert(render->xvmc_id == AV_XVMC_ID);
assert(render->mv_blocks);
......
......@@ -277,10 +277,10 @@ int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
}else{
if(n<4){
wrap= s->linesize;
dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
dest= s->current_picture.f->data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
}else{
wrap= s->uvlinesize;
dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
dest= s->current_picture.f->data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
}
if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
else a= get_dc(dest-8, wrap, scale*8);
......
......@@ -416,7 +416,7 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
ff_MPV_frame_end(s);
f = &s->current_picture.f;
f = s->current_picture.f;
if (v->respic == 3) {
ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h);
......
......@@ -767,7 +767,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
avctx->get_buffer2 == avcodec_default_get_buffer2);
FF_ENABLE_DEPRECATION_WARNINGS
if (!f->f->buf[0])
if (!f->f || !f->f->buf[0])
return;