Skip to content

Commit

Permalink
lavc/videotoolboxenc: use common routine for pixfmt conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
rcombs committed Dec 23, 2021
1 parent 131dbb9 commit 028a6ed
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions libavcodec/videotoolboxenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "libavutil/avstring.h"
#include "libavcodec/avcodec.h"
#include "libavutil/pixdesc.h"
#include "libavutil/hwcontext_videotoolbox.h"
#include "internal.h"
#include <pthread.h>
#include "atsc_a53.h"
Expand Down Expand Up @@ -797,25 +798,9 @@ static int get_cv_pixel_format(AVCodecContext* avctx,
range != AVCOL_RANGE_JPEG;

//MPEG range is used when no range is set
if (fmt == AV_PIX_FMT_NV12) {
*av_pixel_format = range == AVCOL_RANGE_JPEG ?
kCVPixelFormatType_420YpCbCr8BiPlanarFullRange :
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
} else if (fmt == AV_PIX_FMT_YUV420P) {
*av_pixel_format = range == AVCOL_RANGE_JPEG ?
kCVPixelFormatType_420YpCbCr8PlanarFullRange :
kCVPixelFormatType_420YpCbCr8Planar;
} else if (fmt == AV_PIX_FMT_BGRA) {
*av_pixel_format = kCVPixelFormatType_32BGRA;
} else if (fmt == AV_PIX_FMT_P010LE) {
*av_pixel_format = range == AVCOL_RANGE_JPEG ?
kCVPixelFormatType_420YpCbCr10BiPlanarFullRange :
kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
} else {
return AVERROR(EINVAL);
}
*av_pixel_format = av_map_videotoolbox_format_from_pixfmt2(fmt, range == AVCOL_RANGE_JPEG);

return 0;
return *av_pixel_format ? 0 : AVERROR(EINVAL);
}

static void add_color_attr(AVCodecContext *avctx, CFMutableDictionaryRef dict) {
Expand Down

0 comments on commit 028a6ed

Please sign in to comment.