aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-05 15:52:16 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-05 15:58:07 +0100
commit2f980cf39a14f90b9356b51ef1ed6e7816f6aac3 (patch)
treefaf8d16ad3dc12e37a8f2854bdab16192709f42b
parent874c5b02c4117d5261365d0de727c0b4dc9363f6 (diff)
parentff953fecffd3b9a616a046723fb9d4690be032a6 (diff)
downloadffmpeg-2f980cf39a14f90b9356b51ef1ed6e7816f6aac3.tar.gz
Merge commit 'ff953fecffd3b9a616a046723fb9d4690be032a6'
* commit 'ff953fecffd3b9a616a046723fb9d4690be032a6': lavc: set frame properties in ff_get_buffer(). Conflicts: libavcodec/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--cmdutils.c5
-rw-r--r--libavcodec/utils.c28
2 files changed, 20 insertions, 13 deletions
diff --git a/cmdutils.c b/cmdutils.c
index fd8ff50e38..abe5601134 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1657,11 +1657,6 @@ int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
frame->opaque = buf;
frame->type = FF_BUFFER_TYPE_USER;
frame->extended_data = frame->data;
- frame->pkt_pts = s->pkt ? s->pkt->pts : AV_NOPTS_VALUE;
- frame->width = buf->w;
- frame->height = buf->h;
- frame->format = buf->pix_fmt;
- frame->sample_aspect_ratio = s->sample_aspect_ratio;
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
frame->base[i] = buf->base[i]; // XXX h264.c uses base though it shouldn't
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index be6b3a9e23..3bb30d176c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -436,7 +436,6 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
}
frame->type = FF_BUFFER_TYPE_INTERNAL;
- ff_init_buffer_info(avctx, frame);
if (avctx->debug & FF_DEBUG_BUFFERS)
av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, "
@@ -560,11 +559,6 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
}
pic->extended_data = pic->data;
avci->buffer_count++;
- pic->width = buf->width;
- pic->height = buf->height;
- pic->format = buf->pix_fmt;
-
- ff_init_buffer_info(s, pic);
if (s->debug & FF_DEBUG_BUFFERS)
av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d "
@@ -587,6 +581,26 @@ int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
{
+ switch (avctx->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;
+ break;
+ case AVMEDIA_TYPE_AUDIO:
+ frame->sample_rate = avctx->sample_rate;
+ frame->format = avctx->sample_fmt;
+ frame->channel_layout = avctx->channel_layout;
+ break;
+ default: return AVERROR(EINVAL);
+ }
+
+ frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
+ frame->reordered_opaque = avctx->reordered_opaque;
+
+ ff_init_buffer_info(avctx, frame);
+
return avctx->get_buffer(avctx, frame);
}
@@ -2682,8 +2696,6 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
{
f->owner = avctx;
- ff_init_buffer_info(avctx, f);
-
return ff_get_buffer(avctx, f);
}