[FFmpeg-devel,1/2] lavc: Add coded_w/h to AVCodecParameters

Submitted by Zhong Li on Jan. 18, 2018, 5:03 a.m.

Details

Message ID 1516251814-6220-1-git-send-email-zhong.li@intel.com
State Superseded
Headers show

Commit Message

Zhong Li Jan. 18, 2018, 5:03 a.m.
coded_width/height may be different from width/height sometimes
(e.g, crop or lowres cases).
ffprobe always show coded_width/height same as width/height since they
are overwritten.
This fixes tiket #6958.

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/avcodec.h | 7 +++++++
 libavcodec/utils.c   | 4 ++++
 libavcodec/version.h | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

Comments

James Almer Jan. 18, 2018, 5:14 a.m.
On 1/18/2018 2:03 AM, Zhong Li wrote:
> coded_width/height may be different from width/height sometimes

> (e.g, crop or lowres cases).

Which is why it's not a field that belongs to AVCodecParameters.

Codec level cropping has nothing to do with containers. Same with
lowres, which is an internal feature, and scheduled for removal.
Hendrik Leppkes Jan. 18, 2018, 10:40 a.m.
On Thu, Jan 18, 2018 at 6:14 AM, James Almer <jamrial@gmail.com> wrote:
> On 1/18/2018 2:03 AM, Zhong Li wrote:
>> coded_width/height may be different from width/height sometimes
>
>> (e.g, crop or lowres cases).
>
> Which is why it's not a field that belongs to AVCodecParameters.
>
> Codec level cropping has nothing to do with containers. Same with
> lowres, which is an internal feature, and scheduled for removal.

Indeed, the coded w/h are technical details internal to a codec, and
not relevant as a codec parameter.

- Hendrik

Patch hide | download patch | download mbox

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8fbbc79..710e90c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3905,6 +3905,13 @@  typedef struct AVCodecParameters {
     int height;
 
     /**
+     * Video only. The dimensions of the coded 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 4c71843..427f612 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2147,6 +2147,8 @@  int avcodec_parameters_from_context(AVCodecParameters *par,
         par->format              = codec->pix_fmt;
         par->width               = codec->width;
         par->height              = codec->height;
+        par->coded_width         = codec->coded_width;
+        par->coded_height        = codec->coded_height;
         par->field_order         = codec->field_order;
         par->color_range         = codec->color_range;
         par->color_primaries     = codec->color_primaries;
@@ -2202,6 +2204,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;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 47a15d5..ec536bf 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@ 
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   9
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \