[FFmpeg-devel] [PATCH] Add coded_width/height to AVCodecParameters

Michael Niedermayer michael at niedermayer.cc
Sun Apr 3 14:07:47 CEST 2016


Without this or some other change moving data back and forth corrupts it
as the cropped & possibly low res resolution modified w/h will be taken
a the pre lowres resolution
also without 2 sets theres no place to communicate the cropped dimensions

can be reproduced with
./ffplay_g -vlowres 2 tickets/162/avid.avi

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/avcodec.h |    8 +++++++-
 libavcodec/utils.c   |    4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ec45add..19bc1a6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3826,12 +3826,18 @@ typedef struct AVCodecParameters {
     int level;
 
     /**
-     * Video only. The dimensions of the video frame in pixels.
+     * Video only. The dimensions of the presented video frame in pixels.
      */
     int width;
     int height;
 
     /**
+     * Video only. The dimensions of the stored video frame in pixels.
+     */
+    int coded_width;
+    int coded_height;
+
+    /**
      * Video only. The aspect ratio (width / height) which a single pixel
      * should have when displayed.
      *
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a26a5ed..1fd7f29 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3772,6 +3772,8 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
     switch (par->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
         par->format              = codec->pix_fmt;
+        par->coded_width         = codec->coded_width;
+        par->coded_height        = codec->coded_height;
         par->width               = codec->width;
         par->height              = codec->height;
         par->field_order         = codec->field_order;
@@ -3827,6 +3829,8 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
         codec->pix_fmt                = par->format;
         codec->width                  = par->width;
         codec->height                 = par->height;
+        codec->coded_width            = par->coded_width;
+        codec->coded_height           = par->coded_height;
         codec->field_order            = par->field_order;
         codec->color_range            = par->color_range;
         codec->color_primaries        = par->color_primaries;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list