提交 a80e6229 编写于 作者: M Michael Niedermayer

avcodec/avutil: Add AVColorSpace and AVColorRange to AVFrames

This also moves AVColorSpace and AVColorRange from avcodec to avutil
Signed-off-by: NMichael Niedermayer <michaelni@gmx.at>
上级 0092bcdf
......@@ -627,26 +627,6 @@ enum AVColorTransferCharacteristic{
AVCOL_TRC_NB , ///< Not part of ABI
};
enum AVColorSpace{
AVCOL_SPC_RGB = 0,
AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVCOL_SPC_UNSPECIFIED = 2,
AVCOL_SPC_FCC = 4,
AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
AVCOL_SPC_SMPTE240M = 7,
AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
AVCOL_SPC_NB , ///< Not part of ABI
};
#define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
enum AVColorRange{
AVCOL_RANGE_UNSPECIFIED = 0,
AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
AVCOL_RANGE_NB , ///< Not part of ABI
};
/**
* X X 3 4 X X are luma samples,
* 1 2 1-6 are possible chroma positions
......
......@@ -643,6 +643,10 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
frame->format = avctx->pix_fmt;
if (!frame->sample_aspect_ratio.num)
frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
av_frame_set_colorspace(frame, avctx->colorspace);
if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED)
av_frame_set_color_range(frame, avctx->color_range);
break;
case AVMEDIA_TYPE_AUDIO:
if (!frame->sample_rate)
......@@ -964,6 +968,7 @@ void avcodec_get_frame_defaults(AVFrame *frame)
frame->sample_aspect_ratio = (AVRational) {0, 1 };
frame->format = -1; /* unknown */
frame->extended_data = frame->data;
av_frame_set_colorspace(frame, AVCOL_SPC_UNSPECIFIED);
}
AVFrame *avcodec_alloc_frame(void)
......
......@@ -40,6 +40,8 @@ MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata)
MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags)
MAKE_ACCESSORS(AVFrame, frame, int, pkt_size)
MAKE_ACCESSORS(AVFrame, frame, enum AVColorSpace, colorspace)
MAKE_ACCESSORS(AVFrame, frame, enum AVColorRange, color_range)
#define CHECK_CHANNELS_CONSISTENCY(frame) \
av_assert2(!(frame)->channel_layout || \
......@@ -89,6 +91,7 @@ static void get_frame_defaults(AVFrame *frame)
frame->key_frame = 1;
frame->sample_aspect_ratio = (AVRational){ 0, 1 };
frame->format = -1; /* unknown */
frame->colorspace = AVCOL_SPC_UNSPECIFIED;
frame->extended_data = frame->data;
}
......@@ -456,6 +459,8 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
dst->coded_picture_number = src->coded_picture_number;
dst->display_picture_number = src->display_picture_number;
dst->decode_error_flags = src->decode_error_flags;
dst->colorspace = src->colorspace;
dst->color_range = dst->color_range;
av_dict_copy(&dst->metadata, src->metadata, 0);
......
......@@ -30,6 +30,26 @@
#include "rational.h"
#include "samplefmt.h"
enum AVColorSpace{
AVCOL_SPC_RGB = 0,
AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVCOL_SPC_UNSPECIFIED = 2,
AVCOL_SPC_FCC = 4,
AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
AVCOL_SPC_SMPTE240M = 7,
AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
AVCOL_SPC_NB , ///< Not part of ABI
};
#define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
enum AVColorRange{
AVCOL_RANGE_UNSPECIFIED = 0,
AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
AVCOL_RANGE_NB , ///< Not part of ABI
};
enum AVFrameSideDataType {
/**
* The data is the AVPanScan struct defined in libavcodec.
......@@ -432,6 +452,25 @@ typedef struct AVFrame {
*/
int pkt_size;
/**
* YUV colorspace type.
* It must be accessed using av_frame_get_colorspace() and
* av_frame_set_colorspace().
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorSpace colorspace;
/**
* MPEG vs JPEG YUV range.
* It must be accessed using av_frame_get_color_range() and
* av_frame_set_color_range().
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorRange color_range;
/**
* Not to be accessed directly from outside libavutil
*/
......@@ -464,6 +503,10 @@ void av_frame_set_pkt_size(AVFrame *frame, int val);
AVDictionary **avpriv_frame_get_metadatap(AVFrame *frame);
int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val);
enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
/**
* Allocate an AVFrame and set its fields to default values. The resulting
......
......@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 39
#define LIBAVUTIL_VERSION_MINOR 40
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册