[FFmpeg-cvslog] avcodec: do not use AVFrame accessor
Muhammad Faiz
git at videolan.org
Sun Apr 23 11:13:07 EEST 2017
ffmpeg | branch: master | Muhammad Faiz <mfcc64 at gmail.com> | Sat Apr 22 15:54:58 2017 +0700| [31f61b0d4f8d452becb44f044c739f9057900159] | committer: Muhammad Faiz
avcodec: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg at googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31f61b0d4f8d452becb44f044c739f9057900159
---
libavcodec/ac3dec.c | 2 +-
libavcodec/cpia.c | 8 +++----
libavcodec/crystalhd.c | 6 +++---
libavcodec/cuvid.c | 6 +++---
libavcodec/decode.c | 50 +++++++++++++++++++++-----------------------
libavcodec/encode.c | 2 +-
libavcodec/exr.c | 2 +-
libavcodec/gifdec.c | 2 +-
libavcodec/mjpegdec.c | 2 +-
libavcodec/pngdec.c | 2 +-
libavcodec/proresdec2.c | 2 +-
libavcodec/rawdec.c | 4 ++--
libavcodec/tiff.c | 8 +++----
libavcodec/videotoolboxenc.c | 8 +++----
libavcodec/webp.c | 2 +-
15 files changed, 52 insertions(+), 54 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 4a0d8bbcc7..7e2cbce90b 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -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 */
for (ch = 0; ch < s->out_channels; ch++)
diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
index 07cdd50368..58833b2f26 100644
--- a/libavcodec/cpia.c
+++ b/libavcodec/cpia.c
@@ -113,12 +113,12 @@ static int cpia_decode_frame(AVCodecContext *avctx,
src += 2;
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");
break;
}
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]);
break;
}
@@ -139,7 +139,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
*/
for (j = 0; j < linelength - 1; j++) {
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");
break;
}
@@ -159,7 +159,7 @@ static int cpia_decode_frame(AVCodecContext *avctx,
*/
for (j = 0; j < linelength - 4; ) {
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");
break;
}
diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index b1e5c64829..8ccd6ff8bd 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -634,9 +634,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
- av_frame_set_pkt_pos(frame, -1);
- av_frame_set_pkt_duration(frame, 0);
- av_frame_set_pkt_size(frame, -1);
+ frame->pkt_pos = -1;
+ frame->pkt_duration = 0;
+ frame->pkt_size = -1;
if (!priv->need_second_field) {
*got_frame = 1;
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 4d96cf0204..288083423e 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -604,9 +604,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pts = frame->pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- av_frame_set_pkt_pos(frame, -1);
- av_frame_set_pkt_duration(frame, 0);
- av_frame_set_pkt_size(frame, -1);
+ frame->pkt_pos = -1;
+ frame->pkt_duration = 0;
+ frame->pkt_size = -1;
frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index cf2f615eb1..e63384b910 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -151,7 +151,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
memcpy(frame->data, avci->to_free->data, sizeof(frame->data));
memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize));
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);
if (!size) {
@@ -174,7 +174,7 @@ static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
frame->height = avci->to_free->height;
frame->channel_layout = avci->to_free->channel_layout;
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;
}
@@ -417,7 +417,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
frame->pkt_dts = pkt->dts;
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)
/* get_buffer is supposed to set frame parameters */
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
@@ -436,10 +436,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (frame->flags & AV_FRAME_FLAG_DISCARD)
got_frame = 0;
if (got_frame)
- av_frame_set_best_effort_timestamp(frame,
- guess_correct_pts(avctx,
- frame->pts,
- frame->pkt_dts));
+ frame->best_effort_timestamp = guess_correct_pts(avctx,
+ frame->pts,
+ frame->pkt_dts);
} else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
uint8_t *side;
int side_size;
@@ -448,16 +447,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
uint8_t discard_reason = 0;
if (ret >= 0 && got_frame) {
- av_frame_set_best_effort_timestamp(frame,
- guess_correct_pts(avctx,
- frame->pts,
- frame->pkt_dts));
+ frame->best_effort_timestamp = guess_correct_pts(avctx,
+ frame->pts,
+ frame->pkt_dts);
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
if (!frame->channel_layout)
frame->channel_layout = avctx->channel_layout;
- if (!av_frame_get_channels(frame))
- av_frame_set_channels(frame, avctx->channels);
+ if (!frame->channels)
+ frame->channels = avctx->channels;
if (!frame->sample_rate)
frame->sample_rate = avctx->sample_rate;
}
@@ -502,8 +500,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif
if(frame->pkt_dts!=AV_NOPTS_VALUE)
frame->pkt_dts += diff_ts;
- if (av_frame_get_pkt_duration(frame) >= diff_ts)
- av_frame_set_pkt_duration(frame, av_frame_get_pkt_duration(frame) - diff_ts);
+ if (frame->pkt_duration >= diff_ts)
+ frame->pkt_duration -= diff_ts;
} else {
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,
(AVRational){1, avctx->sample_rate},
avctx->pkt_timebase);
- av_frame_set_pkt_duration(frame, diff_ts);
+ frame->pkt_duration = diff_ts;
} else {
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;
}
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 planes = planar ? ch : 1;
@@ -1408,7 +1406,7 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
int size;
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,
AV_PKT_DATA_STRINGS_METADATA, &size);
@@ -1439,9 +1437,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
frame->pkt_pts = pkt->pts;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- av_frame_set_pkt_pos (frame, pkt->pos);
- av_frame_set_pkt_duration(frame, pkt->duration);
- av_frame_set_pkt_size (frame, pkt->size);
+ frame->pkt_pos = pkt->pos;
+ frame->pkt_duration = pkt->duration;
+ frame->pkt_size = pkt->size;
for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
int size;
@@ -1470,10 +1468,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
frame->color_primaries = avctx->color_primaries;
if (frame->color_trc == AVCOL_TRC_UNSPECIFIED)
frame->color_trc = avctx->color_trc;
- if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
- av_frame_set_colorspace(frame, avctx->colorspace);
- if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED)
- av_frame_set_color_range(frame, avctx->color_range);
+ if (frame->colorspace == AVCOL_SPC_UNSPECIFIED)
+ frame->colorspace = avctx->colorspace;
+ if (frame->color_range == AVCOL_RANGE_UNSPECIFIED)
+ frame->color_range = avctx->color_range;
if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
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;
}
return 0;
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 6e9d487306..525ee1f5d6 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -88,7 +88,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
frame->format = src->format;
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;
ret = av_frame_get_buffer(frame, 32);
if (ret < 0)
diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 7cf3620d7f..71946400c5 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1630,7 +1630,7 @@ static int decode_header(EXRContext *s, AVFrame *frame)
return AVERROR_INVALIDDATA;
}
- av_frame_set_metadata(frame, metadata);
+ frame->metadata = metadata;
// aaand we are done
bytestream2_skip(&s->gb, 1);
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 48345db545..2eeed4c4c7 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -468,7 +468,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
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) {
s->keyframe = memcmp(avpkt->data, gif87a_sig, 6) == 0 ||
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 98cbd416e2..a86f6b2642 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -2499,7 +2499,7 @@ the_end:
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);
the_end_no_picture:
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 102551972e..aece1fcd5f 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1171,7 +1171,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
}
}
- metadatap = avpriv_frame_get_metadatap(p);
+ metadatap = &p->metadata;
switch (tag) {
case MKTAG('I', 'H', 'D', 'R'):
if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0)
diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index ff46bcfde0..73b161f9a5 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -622,7 +622,7 @@ static int decode_picture(AVCodecContext *avctx)
error += ctx->slices[i].ret < 0;
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)
return 0;
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 6dcb5f2e66..1893b26444 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -237,8 +237,8 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
if (res < 0)
return res;
- av_frame_set_pkt_pos (frame, avctx->internal->last_pkt_props->pos);
- av_frame_set_pkt_duration(frame, avctx->internal->last_pkt_props->duration);
+ frame->pkt_pos = avctx->internal->last_pkt_props->pos;
+ frame->pkt_duration = avctx->internal->last_pkt_props->duration;
if (context->tff >= 0) {
frame->interlaced_frame = 1;
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index cb1a34e73a..c8e24e33cc 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -227,9 +227,9 @@ static int add_metadata(int count, int type,
const char *name, const char *sep, TiffContext *s, AVFrame *frame)
{
switch(type) {
- case TIFF_DOUBLE: return ff_tadd_doubles_metadata(count, name, sep, &s->gb, s->le, avpriv_frame_get_metadatap(frame));
- case TIFF_SHORT : return ff_tadd_shorts_metadata(count, name, sep, &s->gb, s->le, 0, avpriv_frame_get_metadatap(frame));
- case TIFF_STRING: return ff_tadd_string_metadata(count, name, &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, &frame->metadata);
+ case TIFF_STRING: return ff_tadd_string_metadata(count, name, &s->gb, s->le, &frame->metadata);
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);
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) {
av_log(avctx, AV_LOG_ERROR, "Writing metadata with key '%s' failed\n", keyname);
return ret;
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index f1c1670dd1..638f278cd0 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1826,7 +1826,7 @@ static int get_cv_pixel_info(
{
VTEncContext *vtctx = avctx->priv_data;
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 range_guessed;
int status;
@@ -2073,7 +2073,7 @@ static int create_cv_pixel_buffer(AVCodecContext *avctx,
AV_LOG_ERROR,
"Error: Cannot convert format %d color_range %d: %d\n",
frame->format,
- av_frame_get_color_range(frame),
+ frame->color_range,
status
);
@@ -2341,8 +2341,8 @@ static int vtenc_populate_extradata(AVCodecContext *avctx,
frame->format = avctx->pix_fmt;
frame->width = avctx->width;
frame->height = avctx->height;
- av_frame_set_colorspace(frame, avctx->colorspace);
- av_frame_set_color_range(frame, avctx->color_range);
+ frame->colorspace = avctx->colorspace;
+ frame->color_range = avctx->color_range;
frame->color_trc = avctx->color_trc;
frame->color_primaries = avctx->color_primaries;
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 45abfdc3ca..52a80402e9 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -1489,7 +1489,7 @@ static int webp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
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:
av_dict_free(&exif_metadata);
More information about the ffmpeg-cvslog
mailing list