1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec: do not use AVFrame accessor

Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
This commit is contained in:
Muhammad Faiz 2017-04-22 15:54:58 +07:00
parent fdeab95a82
commit 31f61b0d4f
15 changed files with 52 additions and 54 deletions

View File

@ -1622,7 +1622,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
} }
} }
av_frame_set_decode_error_flags(frame, err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0); frame->decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
/* keep last block for error concealment in next frame */ /* keep last block for error concealment in next frame */
for (ch = 0; ch < s->out_channels; ch++) for (ch = 0; ch < s->out_channels; ch++)

View File

@ -113,12 +113,12 @@ static int cpia_decode_frame(AVCodecContext *avctx,
src += 2; src += 2;
if (src_size < linelength) { if (src_size < linelength) {
av_frame_set_decode_error_flags(frame, FF_DECODE_ERROR_INVALID_BITSTREAM); frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
av_log(avctx, AV_LOG_WARNING, "Frame ended unexpectedly!\n"); av_log(avctx, AV_LOG_WARNING, "Frame ended unexpectedly!\n");
break; break;
} }
if (src[linelength - 1] != EOL) { if (src[linelength - 1] != EOL) {
av_frame_set_decode_error_flags(frame, FF_DECODE_ERROR_INVALID_BITSTREAM); frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
av_log(avctx, AV_LOG_WARNING, "Wrong line length %d or line not terminated properly (found 0x%02x)!\n", linelength, src[linelength - 1]); av_log(avctx, AV_LOG_WARNING, "Wrong line length %d or line not terminated properly (found 0x%02x)!\n", linelength, src[linelength - 1]);
break; break;
} }
@ -139,7 +139,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
*/ */
for (j = 0; j < linelength - 1; j++) { for (j = 0; j < linelength - 1; j++) {
if (y > y_end) { if (y > y_end) {
av_frame_set_decode_error_flags(frame, FF_DECODE_ERROR_INVALID_BITSTREAM); frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
av_log(avctx, AV_LOG_WARNING, "Decoded data exceeded linesize!\n"); av_log(avctx, AV_LOG_WARNING, "Decoded data exceeded linesize!\n");
break; break;
} }
@ -159,7 +159,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
*/ */
for (j = 0; j < linelength - 4; ) { for (j = 0; j < linelength - 4; ) {
if (y + 1 > y_end || u > u_end || v > v_end) { if (y + 1 > y_end || u > u_end || v > v_end) {
av_frame_set_decode_error_flags(frame, FF_DECODE_ERROR_INVALID_BITSTREAM); frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
av_log(avctx, AV_LOG_WARNING, "Decoded data exceeded linesize!\n"); av_log(avctx, AV_LOG_WARNING, "Decoded data exceeded linesize!\n");
break; break;
} }

View File

@ -634,9 +634,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
} }
av_frame_set_pkt_pos(frame, -1); frame->pkt_pos = -1;
av_frame_set_pkt_duration(frame, 0); frame->pkt_duration = 0;
av_frame_set_pkt_size(frame, -1); frame->pkt_size = -1;
if (!priv->need_second_field) { if (!priv->need_second_field) {
*got_frame = 1; *got_frame = 1;

View File

@ -604,9 +604,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pts = frame->pts; frame->pkt_pts = frame->pts;
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
av_frame_set_pkt_pos(frame, -1); frame->pkt_pos = -1;
av_frame_set_pkt_duration(frame, 0); frame->pkt_duration = 0;
av_frame_set_pkt_size(frame, -1); frame->pkt_size = -1;
frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame; frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame;

View File

@ -151,7 +151,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
memcpy(frame->data, avci->to_free->data, sizeof(frame->data)); memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize)); memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
if (avci->to_free->extended_data != avci->to_free->data) { if (avci->to_free->extended_data != avci->to_free->data) {
int planes = av_frame_get_channels(avci->to_free); int planes = avci->to_free->channels;
int size = planes * sizeof(*frame->extended_data); int size = planes * sizeof(*frame->extended_data);
if (!size) { if (!size) {
@ -174,7 +174,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
frame->height = avci->to_free->height; frame->height = avci->to_free->height;
frame->channel_layout = avci->to_free->channel_layout; frame->channel_layout = avci->to_free->channel_layout;
frame->nb_samples = avci->to_free->nb_samples; frame->nb_samples = avci->to_free->nb_samples;
av_frame_set_channels(frame, av_frame_get_channels(avci->to_free)); frame->channels = avci->to_free->channels;
return 0; return 0;
} }
@ -417,7 +417,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
frame->pkt_dts = pkt->dts; frame->pkt_dts = pkt->dts;
if(!avctx->has_b_frames) if(!avctx->has_b_frames)
av_frame_set_pkt_pos(frame, pkt->pos); frame->pkt_pos = pkt->pos;
//FIXME these should be under if(!avctx->has_b_frames) //FIXME these should be under if(!avctx->has_b_frames)
/* get_buffer is supposed to set frame parameters */ /* get_buffer is supposed to set frame parameters */
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
@ -436,10 +436,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (frame->flags & AV_FRAME_FLAG_DISCARD) if (frame->flags & AV_FRAME_FLAG_DISCARD)
got_frame = 0; got_frame = 0;
if (got_frame) if (got_frame)
av_frame_set_best_effort_timestamp(frame, frame->best_effort_timestamp = guess_correct_pts(avctx,
guess_correct_pts(avctx,
frame->pts, frame->pts,
frame->pkt_dts)); frame->pkt_dts);
} else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
uint8_t *side; uint8_t *side;
int side_size; int side_size;
@ -448,16 +447,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
uint8_t discard_reason = 0; uint8_t discard_reason = 0;
if (ret >= 0 && got_frame) { if (ret >= 0 && got_frame) {
av_frame_set_best_effort_timestamp(frame, frame->best_effort_timestamp = guess_correct_pts(avctx,
guess_correct_pts(avctx,
frame->pts, frame->pts,
frame->pkt_dts)); frame->pkt_dts);
if (frame->format == AV_SAMPLE_FMT_NONE) if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt; frame->format = avctx->sample_fmt;
if (!frame->channel_layout) if (!frame->channel_layout)
frame->channel_layout = avctx->channel_layout; frame->channel_layout = avctx->channel_layout;
if (!av_frame_get_channels(frame)) if (!frame->channels)
av_frame_set_channels(frame, avctx->channels); frame->channels = avctx->channels;
if (!frame->sample_rate) if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate; frame->sample_rate = avctx->sample_rate;
} }
@ -502,8 +500,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
if(frame->pkt_dts!=AV_NOPTS_VALUE) if(frame->pkt_dts!=AV_NOPTS_VALUE)
frame->pkt_dts += diff_ts; frame->pkt_dts += diff_ts;
if (av_frame_get_pkt_duration(frame) >= diff_ts) if (frame->pkt_duration >= diff_ts)
av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts); frame->pkt_duration -= diff_ts;
} else { } else {
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n"); av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
} }
@ -523,7 +521,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding, int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding,
(AVRational){1, avctx->sample_rate}, (AVRational){1, avctx->sample_rate},
avctx->pkt_timebase); avctx->pkt_timebase);
av_frame_set_pkt_duration(frame, diff_ts); frame->pkt_duration = diff_ts;
} else { } else {
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n"); av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n");
} }
@ -1253,7 +1251,7 @@ static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame)
break; break;
} }
case AVMEDIA_TYPE_AUDIO: { case AVMEDIA_TYPE_AUDIO: {
int ch = av_frame_get_channels(frame); //av_get_channel_layout_nb_channels(frame->channel_layout); int ch = frame->channels; //av_get_channel_layout_nb_channels(frame->channel_layout);
int planar = av_sample_fmt_is_planar(frame->format); int planar = av_sample_fmt_is_planar(frame->format);
int planes = planar ? ch : 1; int planes = planar ? ch : 1;
@ -1408,7 +1406,7 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
int size; int size;
const uint8_t *side_metadata; const uint8_t *side_metadata;
AVDictionary **frame_md = avpriv_frame_get_metadatap(frame); AVDictionary **frame_md = &frame->metadata;
side_metadata = av_packet_get_side_data(avpkt, side_metadata = av_packet_get_side_data(avpkt,
AV_PKT_DATA_STRINGS_METADATA, &size); AV_PKT_DATA_STRINGS_METADATA, &size);
@ -1439,9 +1437,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pts = pkt->pts; frame->pkt_pts = pkt->pts;
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
av_frame_set_pkt_pos (frame, pkt->pos); frame->pkt_pos = pkt->pos;
av_frame_set_pkt_duration(frame, pkt->duration); frame->pkt_duration = pkt->duration;
av_frame_set_pkt_size (frame, pkt->size); frame->pkt_size = pkt->size;
for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) { for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
int size; int size;
@ -1470,10 +1468,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
frame->color_primaries = avctx->color_primaries; frame->color_primaries = avctx->color_primaries;
if (frame->color_trc == AVCOL_TRC_UNSPECIFIED) if (frame->color_trc == AVCOL_TRC_UNSPECIFIED)
frame->color_trc = avctx->color_trc; frame->color_trc = avctx->color_trc;
if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED) if (frame->colorspace == AVCOL_SPC_UNSPECIFIED)
av_frame_set_colorspace(frame, avctx->colorspace); frame->colorspace = avctx->colorspace;
if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED) if (frame->color_range == AVCOL_RANGE_UNSPECIFIED)
av_frame_set_color_range(frame, avctx->color_range); frame->color_range = avctx->color_range;
if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED) if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
frame->chroma_location = avctx->chroma_sample_location; frame->chroma_location = avctx->chroma_sample_location;
@ -1516,7 +1514,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
} }
} }
} }
av_frame_set_channels(frame, avctx->channels); frame->channels = avctx->channels;
break; break;
} }
return 0; return 0;

View File

@ -88,7 +88,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
frame->format = src->format; frame->format = src->format;
frame->channel_layout = src->channel_layout; frame->channel_layout = src->channel_layout;
av_frame_set_channels(frame, av_frame_get_channels(src)); frame->channels = src->channels;
frame->nb_samples = s->frame_size; frame->nb_samples = s->frame_size;
ret = av_frame_get_buffer(frame, 32); ret = av_frame_get_buffer(frame, 32);
if (ret < 0) if (ret < 0)

View File

@ -1630,7 +1630,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
av_frame_set_metadata(frame, metadata); frame->metadata = metadata;
// aaand we are done // aaand we are done
bytestream2_skip(&s->gb, 1); bytestream2_skip(&s->gb, 1);

View File

@ -468,7 +468,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
s->frame->pkt_dts = avpkt->dts; s->frame->pkt_dts = avpkt->dts;
av_frame_set_pkt_duration(s->frame, avpkt->duration); s->frame->pkt_duration = avpkt->duration;
if (avpkt->size >= 6) { if (avpkt->size >= 6) {
s->keyframe = memcmp(avpkt->data, gif87a_sig, 6) == 0 || s->keyframe = memcmp(avpkt->data, gif87a_sig, 6) == 0 ||

View File

@ -2499,7 +2499,7 @@ the_end:
av_freep(&s->stereo3d); av_freep(&s->stereo3d);
} }
av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0); av_dict_copy(&((AVFrame *) data)->metadata, s->exif_metadata, 0);
av_dict_free(&s->exif_metadata); av_dict_free(&s->exif_metadata);
the_end_no_picture: the_end_no_picture:

View File

@ -1171,7 +1171,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
} }
} }
metadatap = avpriv_frame_get_metadatap(p); metadatap = &p->metadata;
switch (tag) { switch (tag) {
case MKTAG('I', 'H', 'D', 'R'): case MKTAG('I', 'H', 'D', 'R'):
if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0) if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0)

View File

@ -622,7 +622,7 @@ static int decode_picture(AVCodecContext *avctx)
error += ctx->slices[i].ret < 0; error += ctx->slices[i].ret < 0;
if (error) if (error)
av_frame_set_decode_error_flags(ctx->frame, FF_DECODE_ERROR_INVALID_BITSTREAM); ctx->frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
if (error < ctx->slice_count) if (error < ctx->slice_count)
return 0; return 0;

View File

@ -237,8 +237,8 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
if (res < 0) if (res < 0)
return res; return res;
av_frame_set_pkt_pos (frame, avctx->internal->last_pkt_props->pos); frame->pkt_pos = avctx->internal->last_pkt_props->pos;
av_frame_set_pkt_duration(frame, avctx->internal->last_pkt_props->duration); frame->pkt_duration = avctx->internal->last_pkt_props->duration;
if (context->tff >= 0) { if (context->tff >= 0) {
frame->interlaced_frame = 1; frame->interlaced_frame = 1;

View File

@ -227,9 +227,9 @@ static int add_metadata(int count, int type,
const char *name, const char *sep, TiffContext *s, AVFrame *frame) const char *name, const char *sep, TiffContext *s, AVFrame *frame)
{ {
switch(type) { switch(type) {
case TIFF_DOUBLE: return ff_tadd_doubles_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame)); case TIFF_DOUBLE: return ff_tadd_doubles_metadata(count, name, sep, &s->gb, s->le, &frame->metadata);
case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, 0, avpriv_frame_get_metadatap(frame)); case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, 0, &frame->metadata);
case TIFF_STRING: return ff_tadd_string_metadata(count, name, &s->gb, s->le, avpriv_frame_get_metadatap(frame)); case TIFF_STRING: return ff_tadd_string_metadata(count, name, &s->gb, s->le, &frame->metadata);
default : return AVERROR_INVALIDDATA; default : return AVERROR_INVALIDDATA;
}; };
} }
@ -1255,7 +1255,7 @@ static int decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_WARNING, "Type of GeoTIFF key %d is wrong\n", s->geotags[i].key); av_log(avctx, AV_LOG_WARNING, "Type of GeoTIFF key %d is wrong\n", s->geotags[i].key);
continue; continue;
} }
ret = av_dict_set(avpriv_frame_get_metadatap(p), keyname, s->geotags[i].val, 0); ret = av_dict_set(&p->metadata, keyname, s->geotags[i].val, 0);
if (ret<0) { if (ret<0) {
av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname); av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname);
return ret; return ret;

View File

@ -1826,7 +1826,7 @@ static int get_cv_pixel_info(
{ {
VTEncContext *vtctx = avctx->priv_data; VTEncContext *vtctx = avctx->priv_data;
int av_format = frame->format; int av_format = frame->format;
int av_color_range = av_frame_get_color_range(frame); int av_color_range = frame->color_range;
int i; int i;
int range_guessed; int range_guessed;
int status; int status;
@ -2073,7 +2073,7 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx,
AV_LOG_ERROR, AV_LOG_ERROR,
"Error: Cannot convert format %d color_range %d: %d\n", "Error: Cannot convert format %d color_range %d: %d\n",
frame->format, frame->format,
av_frame_get_color_range(frame), frame->color_range,
status status
); );
@ -2341,8 +2341,8 @@ static int vtenc_populate_extradata(AVCodecContext *avctx,
frame->format = avctx->pix_fmt; frame->format = avctx->pix_fmt;
frame->width = avctx->width; frame->width = avctx->width;
frame->height = avctx->height; frame->height = avctx->height;
av_frame_set_colorspace(frame, avctx->colorspace); frame->colorspace = avctx->colorspace;
av_frame_set_color_range(frame, avctx->color_range); frame->color_range = avctx->color_range;
frame->color_trc = avctx->color_trc; frame->color_trc = avctx->color_trc;
frame->color_primaries = avctx->color_primaries; frame->color_primaries = avctx->color_primaries;

View File

@ -1489,7 +1489,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
goto exif_end; goto exif_end;
} }
av_dict_copy(avpriv_frame_get_metadatap(data), exif_metadata, 0); av_dict_copy(&((AVFrame *) data)->metadata, exif_metadata, 0);
exif_end: exif_end:
av_dict_free(&exif_metadata); av_dict_free(&exif_metadata);