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

Clément Bœsch u at pkh.me
Sun Apr 3 22:49:56 CEST 2016


On Sun, Apr 03, 2016 at 02:07:47PM +0200, Michael Niedermayer wrote:
> 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;

dv needed something like this too, but the code was pretty much hacky in
the first place and it was changed not to use them, which avoided such
commit. Where is this needed exactly?

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160403/8cb4fe1d/attachment.sig>


More information about the ffmpeg-devel mailing list