[FFmpeg-cvslog] lavc: add format field to AVFrame

Stefano Sabatini git at videolan.org
Sat May 7 12:09:26 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Sun May  1 14:10:20 2011 +0200| [18ded93ab3db5996cd86fe2f5b36ba3c4bd58711] | committer: Stefano Sabatini

lavc: add format field to AVFrame

The format is a per-frame property, having it in AVFrame simplify the
operation of extraction of that information, since avoids the need to
access the codec/stream context.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18ded93ab3db5996cd86fe2f5b36ba3c4bd58711
---

 doc/APIchanges            |    3 +++
 libavcodec/avcodec.h      |    9 +++++++++
 libavcodec/utils.c        |    3 +++
 libavcodec/version.h      |    2 +-
 libavfilter/vsrc_buffer.c |    1 +
 5 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a17922e..e46ee48 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-05-07 - xxxxxxx - lavc 53.5.0 - AVFrame
+  Add format field to AVFrame.
+
 2011-05-07 - xxxxxxx - lavc 53.4.0 - AVFrame
   Add width and height fields to AVFrame.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e26fcc2..acdb183 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 dc26092..5e0aa84 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){
@@ -743,6 +744,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/libavcodec/version.h b/libavcodec/version.h
index 362c4f1..56d1eac 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR  4
+#define LIBAVCODEC_VERSION_MINOR  5
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 8445671..b094e99 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -104,6 +104,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;



More information about the ffmpeg-cvslog mailing list