[FFmpeg-devel] [PATCH] avcodec/mjpeg: don't override color information from demuxer
Hendrik Leppkes
h.leppkes at gmail.com
Wed Dec 5 01:57:43 EET 2018
On Wed, Dec 5, 2018 at 12:35 AM Steinar H. Gunderson
<steinar+ffmpeg at gunderson.no> wrote:
>
> Some demuxers, like Matroska, allow for sending colorspace information
> that override MJPEG defaults when it comes to Y'CbCr coefficients or
> chroma location. Don't override such data if the demuxer already has
> set it; this allows decoding such MJPEG streams correctly.
>
> Also document in avcodec.h that these fields are actually set first by
> libavformat, even if libavcodec is usually the one to set them. This is
> not new behavior; e.g., dnxhd already works this way.
> ---
> libavcodec/avcodec.h | 10 +++++-----
> libavcodec/mjpegdec.c | 8 ++++++--
> tests/fate/matroska.mak | 3 +++
> tests/ref/fate/matroska-mjpeg-color-space | 22 ++++++++++++++++++++++
> 4 files changed, 36 insertions(+), 7 deletions(-)
> create mode 100644 tests/ref/fate/matroska-mjpeg-color-space
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 3922e89331..b7ea99d8ab 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2145,35 +2145,35 @@ typedef struct AVCodecContext {
> /**
> * Chromaticity coordinates of the source primaries.
> * - encoding: Set by user
> - * - decoding: Set by libavcodec
> + * - decoding: Set by libavformat and/or libavcodec
> */
> enum AVColorPrimaries color_primaries;
>
> /**
> * Color Transfer Characteristic.
> * - encoding: Set by user
> - * - decoding: Set by libavcodec
> + * - decoding: Set by libavformat and/or libavcodec
> */
> enum AVColorTransferCharacteristic color_trc;
>
> /**
> * YUV colorspace type.
> * - encoding: Set by user
> - * - decoding: Set by libavcodec
> + * - decoding: Set by libavformat and/or libavcodec
> */
> enum AVColorSpace colorspace;
>
> /**
> * MPEG vs JPEG YUV range.
> * - encoding: Set by user
> - * - decoding: Set by libavcodec
> + * - decoding: Set by libavformat and/or libavcodec
> */
> enum AVColorRange color_range;
>
> /**
> * This defines the location of chroma samples.
> * - encoding: Set by user
> - * - decoding: Set by libavcodec
> + * - decoding: Set by libavformat and/or libavcodec
> */
> enum AVChromaLocation chroma_sample_location;
>
These comments are not accurate. avformat does not fill these values,
because outside of deprecated code it does not expose such a struct to
the user.
- Hendrik
More information about the ffmpeg-devel
mailing list