From: Stefano Sabatini <[email protected]>

width and height are per-frame properties, setting these values in
AVFrame simplify the operation of extraction of that information,
since avoids the need to check the codec/stream context.
---
 libavcodec/avcodec.h |    7 +++++++
 libavcodec/utils.c   |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 108e8b0..9cee89d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1265,6 +1265,13 @@ typedef struct AVFrame {
      * - decoding: Read by user.
      */
     AVRational sample_aspect_ratio;
+
+    /**
+     * width and height of the video frame
+     * - encoding: unused
+     * - decoding: Read by user.
+     */
+    int width, height;
 } AVFrame;
 
 struct AVCodecInternal;
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1351445..27e1a6b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -861,6 +861,10 @@ int attribute_align_arg 
avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
             picture->pkt_dts= avpkt->dts;
             if (!picture->sample_aspect_ratio.num)
                 picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
+            if (!picture->width)
+                picture->width = avctx->width;
+            if (!picture->height)
+                picture->height = avctx->height;
         }
 
         emms_c(); //needed to avoid an emms_c() call before every return;
-- 
1.7.7.3

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to