mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
pixdesc: add av_pix_fmt_get_chroma_sub_sample
Deprecate avcodec_get_chroma_sub_sample.
This commit is contained in:
parent
22a0827dff
commit
c1a02e884a
@ -1322,7 +1322,9 @@ static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbu
|
||||
*/
|
||||
memset(buf->base[0], 128, ret);
|
||||
|
||||
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(s->pix_fmt,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {
|
||||
const int h_shift = i==0 ? 0 : h_chroma_shift;
|
||||
const int v_shift = i==0 ? 0 : v_chroma_shift;
|
||||
|
@ -4285,7 +4285,11 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
|
||||
* @{
|
||||
*/
|
||||
|
||||
void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
|
||||
/**
|
||||
* @deprecated Use av_pix_fmt_get_chroma_sub_sample
|
||||
*/
|
||||
|
||||
void attribute_deprecated avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
|
||||
|
||||
/**
|
||||
* Return a value representing the fourCC code associated to the
|
||||
|
@ -725,8 +725,8 @@ static av_cold int ffv1_encode_init(AVCodecContext *avctx)
|
||||
if (!s->transparency)
|
||||
s->plane_count = 2;
|
||||
|
||||
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift,
|
||||
&s->chroma_v_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift,
|
||||
&s->chroma_v_shift);
|
||||
|
||||
s->picture_number = 0;
|
||||
|
||||
|
@ -197,7 +197,8 @@ static av_cold int encode_init(AVCodecContext* avc_context)
|
||||
av_log(avc_context, AV_LOG_ERROR, "Unsupported pix_fmt\n");
|
||||
return -1;
|
||||
}
|
||||
avcodec_get_chroma_sub_sample(avc_context->pix_fmt, &h->uv_hshift, &h->uv_vshift);
|
||||
av_pix_fmt_get_chroma_sub_sample(avc_context->pix_fmt,
|
||||
&h->uv_hshift, &h->uv_vshift);
|
||||
|
||||
if (avc_context->flags & CODEC_FLAG_QSCALE) {
|
||||
/* to be constant with the libvorbis implementation, clip global_quality to 0 - 10
|
||||
|
@ -867,8 +867,9 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
|
||||
|
||||
if (s->width && s->height) {
|
||||
/* set chroma shifts */
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift,
|
||||
&s->chroma_y_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||
&s->chroma_x_shift,
|
||||
&s->chroma_y_shift);
|
||||
|
||||
/* convert fourcc to upper case */
|
||||
s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
|
||||
@ -1781,8 +1782,8 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
|
||||
(s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
|
||||
s->low_delay = 0; // needed to see the vectors without trashing the buffers
|
||||
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||
&h_chroma_shift, &v_chroma_shift);
|
||||
for (i = 0; i < 3; i++) {
|
||||
memcpy(s->visualization_buffer[i], pict->data[i],
|
||||
(i == 0) ? pict->linesize[i] * height:
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "libavutil/intmath.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
@ -601,8 +602,8 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
|
||||
if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS)
|
||||
s->inter_quant_bias = avctx->inter_quant_bias;
|
||||
|
||||
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
|
||||
&chroma_v_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
|
||||
&chroma_v_shift);
|
||||
|
||||
if (avctx->codec_id == AV_CODEC_ID_MPEG4 &&
|
||||
s->avctx->time_base.den > (1 << 16) - 1) {
|
||||
@ -994,8 +995,9 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg)
|
||||
// empty
|
||||
} else {
|
||||
int h_chroma_shift, v_chroma_shift;
|
||||
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift,
|
||||
&v_chroma_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt,
|
||||
&h_chroma_shift,
|
||||
&v_chroma_shift);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
int src_stride = pic_arg->linesize[i];
|
||||
|
@ -270,8 +270,8 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
|
||||
case AV_PIX_FMT_YUV410P:
|
||||
case AV_PIX_FMT_YUV411P:
|
||||
s->photometric_interpretation = 6;
|
||||
avcodec_get_chroma_sub_sample(avctx->pix_fmt,
|
||||
&shift_h, &shift_v);
|
||||
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
|
||||
&shift_h, &shift_v);
|
||||
s->bpp = 8 + (16 >> (shift_h + shift_v));
|
||||
s->subsampling[0] = 1 << shift_h;
|
||||
s->subsampling[1] = 1 << shift_v;
|
||||
|
@ -427,7 +427,8 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
|
||||
const int pixel_size = desc->comp[0].step_minus1 + 1;
|
||||
|
||||
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift,
|
||||
&v_chroma_shift);
|
||||
|
||||
avcodec_align_dimensions2(s, &w, &h, stride_align);
|
||||
|
||||
|
@ -1687,7 +1687,8 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
|
||||
for (i = 0; i < 3; i++)
|
||||
s->qps[i] = -1;
|
||||
|
||||
avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
|
||||
av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift,
|
||||
&s->chroma_y_shift);
|
||||
|
||||
s->y_superblock_width = (s->width + 31) / 32;
|
||||
s->y_superblock_height = (s->height + 31) / 32;
|
||||
|
@ -1454,3 +1454,15 @@ enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
|
||||
|
||||
return desc - av_pix_fmt_descriptors;
|
||||
}
|
||||
|
||||
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
|
||||
int *h_shift, int *v_shift)
|
||||
{
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
|
||||
if (!desc)
|
||||
return AVERROR(ENOSYS);
|
||||
*h_shift = desc->log2_chroma_w;
|
||||
*v_shift = desc->log2_chroma_h;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -203,4 +203,18 @@ const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
|
||||
*/
|
||||
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
|
||||
|
||||
/**
|
||||
* Utility function to access log2_chroma_w log2_chroma_h from
|
||||
* the pixel format AVPixFmtDescriptor.
|
||||
*
|
||||
* @param[in] pix_fmt the pixel format
|
||||
* @param[out] h_shift store log2_chroma_h
|
||||
* @param[out] v_shift store log2_chroma_w
|
||||
*
|
||||
* @return 0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format
|
||||
*/
|
||||
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
|
||||
int *h_shift, int *v_shift);
|
||||
|
||||
|
||||
#endif /* AVUTIL_PIXDESC_H */
|
||||
|
Loading…
Reference in New Issue
Block a user