[FFmpeg-devel] [PATCH] lavc: add format field to AVFrame
Stefano Sabatini
stefano.sabatini-lala at poste.it
Sun May 1 15:56:34 CEST 2011
The format is a per-frame properties, having it in AVFrame simplify
the operation of extraction of that information, since there is no need
to access the codec/stream context.
---
libavcodec/avcodec.h | 9 +++++++++
libavcodec/utils.c | 3 +++
libavfilter/vsrc_buffer.c | 1 +
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9d30a59..9a3f3e9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1025,6 +1025,15 @@ typedef struct AVPanScan{
* - decoding: Read by user.\
*/\
int width, height;\
+\
+ /**\
+ * format of the frame, -1 if unknown or unset\
+ * It should be cast to the corresponding enum (enum PixelFormat\
+ * for video, enum AVSampleFormat for audio)\
+ * - encoding: unused\
+ * - decoding: Read by user.\
+ */\
+ int format;\
#define FF_QSCALE_TYPE_MPEG1 0
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 53eedd6..cbf0c61 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -456,6 +456,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
pic->pkt_pos = -1;
pic->key_frame= 1;
pic->sample_aspect_ratio = (AVRational){0, 1};
+ pic->format = -1; /* unknown */
}
AVFrame *avcodec_alloc_frame(void){
@@ -744,6 +745,8 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
picture->width = avctx->width;
if (!picture->height)
picture->height = avctx->height;
+ if (picture->format == PIX_FMT_NONE)
+ picture->format = avctx->pix_fmt;
}
emms_c(); //needed to avoid an emms_c() call before every return;
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 8c0073f..222ff81 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -102,6 +102,7 @@ int av_vsrc_buffer_add_frame2(AVFilterContext *buffer_filter, AVFrame *frame,
memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize));
c->frame.width = frame->width;
c->frame.height = frame->height;
+ c->frame.format = frame->format;
c->frame.interlaced_frame= frame->interlaced_frame;
c->frame.top_field_first = frame->top_field_first;
c->frame.key_frame = frame->key_frame;
--
1.7.2.3
More information about the ffmpeg-devel
mailing list