[FFmpeg-cvslog] lavc: move ff_init_buffer_info() down to ff_get_buffer()
Michael Niedermayer
git at videolan.org
Wed Dec 5 16:03:20 CET 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Dec 5 15:58:37 2012 +0100| [d2a3f08dafed1f1136e2a9b5ce001a637cafb865] | committer: Michael Niedermayer
lavc: move ff_init_buffer_info() down to ff_get_buffer()
and remove redundant code from ff_get_buffer()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d2a3f08dafed1f1136e2a9b5ce001a637cafb865
---
libavcodec/utils.c | 66 +++++++++++++++++++---------------------------------
1 file changed, 24 insertions(+), 42 deletions(-)
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 3bb30d1..4db9471 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -303,35 +303,6 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
*width = FFALIGN(*width, align);
}
-void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
-{
- if (s->pkt) {
- frame->pkt_pts = s->pkt->pts;
- frame->pkt_pos = s->pkt->pos;
- frame->pkt_duration = s->pkt->duration;
- } else {
- frame->pkt_pts = AV_NOPTS_VALUE;
- frame->pkt_pos = -1;
- frame->pkt_duration = 0;
- }
- frame->reordered_opaque = s->reordered_opaque;
-
- switch (s->codec->type) {
- case AVMEDIA_TYPE_VIDEO:
- frame->width = s->width;
- frame->height = s->height;
- frame->format = s->pix_fmt;
- frame->sample_aspect_ratio = s->sample_aspect_ratio;
- break;
- case AVMEDIA_TYPE_AUDIO:
- frame->sample_rate = s->sample_rate;
- frame->format = s->sample_fmt;
- frame->channel_layout = s->channel_layout;
- frame->channels = s->channels;
- break;
- }
-}
-
int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
enum AVSampleFormat sample_fmt, const uint8_t *buf,
int buf_size, int align)
@@ -579,26 +550,37 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
}
}
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
+void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
{
- switch (avctx->codec_type) {
+ if (s->pkt) {
+ frame->pkt_pts = s->pkt->pts;
+ frame->pkt_pos = s->pkt->pos;
+ frame->pkt_duration = s->pkt->duration;
+ } else {
+ frame->pkt_pts = AV_NOPTS_VALUE;
+ frame->pkt_pos = -1;
+ frame->pkt_duration = 0;
+ }
+ frame->reordered_opaque = s->reordered_opaque;
+
+ switch (s->codec->type) {
case AVMEDIA_TYPE_VIDEO:
- frame->width = avctx->width;
- frame->height = avctx->height;
- frame->format = avctx->pix_fmt;
- frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
+ frame->width = s->width;
+ frame->height = s->height;
+ frame->format = s->pix_fmt;
+ frame->sample_aspect_ratio = s->sample_aspect_ratio;
break;
case AVMEDIA_TYPE_AUDIO:
- frame->sample_rate = avctx->sample_rate;
- frame->format = avctx->sample_fmt;
- frame->channel_layout = avctx->channel_layout;
+ frame->sample_rate = s->sample_rate;
+ frame->format = s->sample_fmt;
+ frame->channel_layout = s->channel_layout;
+ frame->channels = s->channels;
break;
- default: return AVERROR(EINVAL);
}
+}
- frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
- frame->reordered_opaque = avctx->reordered_opaque;
-
+int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
+{
ff_init_buffer_info(avctx, frame);
return avctx->get_buffer(avctx, frame);
More information about the ffmpeg-cvslog
mailing list