MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / prepare_sei_data_array

Function prepare_sei_data_array

libavcodec/nvenc.c:2840–2950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2838}
2839
2840static int prepare_sei_data_array(AVCodecContext *avctx, const AVFrame *frame)
2841{
2842 NvencContext *ctx = avctx->priv_data;
2843 int sei_count = 0;
2844 int i, res;
2845
2846 if (ctx->a53_cc && av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC)) {
2847 void *a53_data = NULL;
2848 size_t a53_size = 0;
2849
2850 if (ff_alloc_a53_sei(frame, 0, &a53_data, &a53_size) < 0) {
2851 av_log(ctx, AV_LOG_ERROR, "Not enough memory for closed captions, skipping\n");
2852 }
2853
2854 if (a53_data) {
2855 void *tmp = av_fast_realloc(ctx->sei_data,
2856 &ctx->sei_data_size,
2857 (sei_count + 1) * sizeof(*ctx->sei_data));
2858 if (!tmp) {
2859 av_free(a53_data);
2860 res = AVERROR(ENOMEM);
2861 goto error;
2862 } else {
2863 ctx->sei_data = tmp;
2864 ctx->sei_data[sei_count].payloadSize = (uint32_t)a53_size;
2865 ctx->sei_data[sei_count].payload = (uint8_t*)a53_data;
2866
2867#if CONFIG_AV1_NVENC_ENCODER
2868 if (avctx->codec->id == AV_CODEC_ID_AV1)
2869 ctx->sei_data[sei_count].payloadType = AV1_METADATA_TYPE_ITUT_T35;
2870 else
2871#endif
2872 ctx->sei_data[sei_count].payloadType = SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35;
2873
2874 sei_count++;
2875 }
2876 }
2877 }
2878
2879 if (ctx->s12m_tc && avctx->codec->id != AV_CODEC_ID_H264 && av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE)) {
2880 void *tc_data = NULL;
2881 size_t tc_size = 0;
2882
2883 if (ff_alloc_timecode_sei(frame, avctx->framerate, 0, &tc_data, &tc_size) < 0) {
2884 av_log(ctx, AV_LOG_ERROR, "Not enough memory for timecode sei, skipping\n");
2885 }
2886
2887 if (tc_data) {
2888 void *tmp = av_fast_realloc(ctx->sei_data,
2889 &ctx->sei_data_size,
2890 (sei_count + 1) * sizeof(*ctx->sei_data));
2891 if (!tmp) {
2892 av_free(tc_data);
2893 res = AVERROR(ENOMEM);
2894 goto error;
2895 } else {
2896 ctx->sei_data = tmp;
2897 ctx->sei_data[sei_count].payloadSize = (uint32_t)tc_size;

Callers 1

nvenc_send_frameFunction · 0.85

Calls 8

av_frame_get_side_dataFunction · 0.85
ff_alloc_a53_seiFunction · 0.85
av_logFunction · 0.85
av_fast_reallocFunction · 0.85
ff_alloc_timecode_seiFunction · 0.85
av_memdupFunction · 0.85
av_freepFunction · 0.85
av_freeFunction · 0.50

Tested by

no test coverage detected