#include "libavutil/pixdesc.h"
#include "internal.h"
#include <pthread.h>
+#include "atsc_a53.h"
#include "h264.h"
#include "h264_sei.h"
#include <dlfcn.h>
CFStringRef kVTProfileLevel_H264_High_5_1;
CFStringRef kVTProfileLevel_H264_High_5_2;
CFStringRef kVTProfileLevel_H264_High_AutoLevel;
+ CFStringRef kVTProfileLevel_H264_Extended_5_0;
+ CFStringRef kVTProfileLevel_H264_Extended_AutoLevel;
CFStringRef kVTProfileLevel_HEVC_Main_AutoLevel;
CFStringRef kVTProfileLevel_HEVC_Main10_AutoLevel;
GET_SYM(kVTProfileLevel_H264_High_5_1, "H264_High_5_1");
GET_SYM(kVTProfileLevel_H264_High_5_2, "H264_High_5_2");
GET_SYM(kVTProfileLevel_H264_High_AutoLevel, "H264_High_AutoLevel");
+ GET_SYM(kVTProfileLevel_H264_Extended_5_0, "H264_Extended_5_0");
+ GET_SYM(kVTProfileLevel_H264_Extended_AutoLevel, "H264_Extended_AutoLevel");
GET_SYM(kVTProfileLevel_HEVC_Main_AutoLevel, "HEVC_Main_AutoLevel");
GET_SYM(kVTProfileLevel_HEVC_Main10_AutoLevel, "HEVC_Main10_AutoLevel");
H264_PROF_BASELINE,
H264_PROF_MAIN,
H264_PROF_HIGH,
+ H264_PROF_EXTENDED,
H264_PROF_COUNT
} VT_H264Profile;
bool flushing;
bool has_b_frames;
bool warned_color_range;
- bool a53_cc;
+
+ /* can't be bool type since AVOption will access it as int */
+ int a53_cc;
} VTEncContext;
static int vtenc_populate_extradata(AVCodecContext *avctx,
return 0;
}
- while (!vtctx->q_head && !vtctx->async_error && wait) {
+ while (!vtctx->q_head && !vtctx->async_error && wait && !vtctx->flushing) {
pthread_cond_wait(&vtctx->cv_sample_sent, &vtctx->lock);
}
vtctx->q_tail = NULL;
}
+ vtctx->frame_ct_out++;
pthread_mutex_unlock(&vtctx->lock);
*buf = info->cm_buffer;
}
av_free(info);
- vtctx->frame_ct_out++;
return 0;
}
info->next = NULL;
pthread_mutex_lock(&vtctx->lock);
- pthread_cond_signal(&vtctx->cv_sample_sent);
if (!vtctx->q_head) {
vtctx->q_head = info;
vtctx->q_tail = info;
+ pthread_cond_signal(&vtctx->cv_sample_sent);
pthread_mutex_unlock(&vtctx->lock);
}
ExtraSEI *sei = sourceFrameCtx;
if (vtctx->async_error) {
- if(sample_buffer) CFRelease(sample_buffer);
return;
}
compat_keys.kVTProfileLevel_H264_High_5_2; break;
}
break;
+ case H264_PROF_EXTENDED:
+ switch (vtctx->level) {
+ case 0: *profile_level_val =
+ compat_keys.kVTProfileLevel_H264_Extended_AutoLevel; break;
+ case 50: *profile_level_val =
+ compat_keys.kVTProfileLevel_H264_Extended_5_0; break;
+ }
+ break;
}
if (!*profile_level_val) {
*av_pixel_format = range == AVCOL_RANGE_JPEG ?
kCVPixelFormatType_420YpCbCr10BiPlanarFullRange :
kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
- *av_pixel_format = kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange;
} else {
return AVERROR(EINVAL);
}
*primaries = NULL;
break;
+ case AVCOL_PRI_BT470BG:
+ *primaries = kCVImageBufferColorPrimaries_EBU_3213;
+ break;
+
+ case AVCOL_PRI_SMPTE170M:
+ *primaries = kCVImageBufferColorPrimaries_SMPTE_C;
+ break;
+
case AVCOL_PRI_BT709:
*primaries = kCVImageBufferColorPrimaries_ITU_R_709_2;
break;
}
}
- if (vtctx->codec_id == AV_CODEC_ID_H264) {
- // kVTCompressionPropertyKey_ProfileLevel is not available for HEVC
- if (profile_level) {
- status = VTSessionSetProperty(vtctx->session,
- kVTCompressionPropertyKey_ProfileLevel,
- profile_level);
- if (status) {
- av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d\n", status);
- }
+ if (profile_level) {
+ status = VTSessionSetProperty(vtctx->session,
+ kVTCompressionPropertyKey_ProfileLevel,
+ profile_level);
+ if (status) {
+ av_log(avctx, AV_LOG_ERROR, "Error setting profile/level property: %d. Output will be encoded using a supported profile/level combination.\n", status);
}
}
{
VTEncContext *vtctx = avctx->priv_data;
- pthread_cond_destroy(&vtctx->cv_sample_sent);
- pthread_mutex_destroy(&vtctx->lock);
-
- if(!vtctx->session) return 0;
+ if(!vtctx->session) {
+ pthread_cond_destroy(&vtctx->cv_sample_sent);
+ pthread_mutex_destroy(&vtctx->lock);
+ return 0;
+ }
VTCompressionSessionCompleteFrames(vtctx->session,
kCMTimeIndefinite);
clear_frame_queue(vtctx);
+ pthread_cond_destroy(&vtctx->cv_sample_sent);
+ pthread_mutex_destroy(&vtctx->lock);
CFRelease(vtctx->session);
vtctx->session = NULL;
{ "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_BASELINE }, INT_MIN, INT_MAX, VE, "profile" },
{ "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" },
{ "high", "High Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_HIGH }, INT_MIN, INT_MAX, VE, "profile" },
+ { "extended", "Extend Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_EXTENDED }, INT_MIN, INT_MAX, VE, "profile" },
{ "level", "Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, VE, "level" },
{ "1.3", "Level 1.3, only available with Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = 13 }, INT_MIN, INT_MAX, VE, "level" },