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

Function parse_feedback_units

libavcodec/vulkan_encode_h265.c:1203–1255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203static int parse_feedback_units(AVCodecContext *avctx,
1204 const uint8_t *data, size_t size,
1205 int sps_override, int pps_override)
1206{
1207 int err;
1208 VulkanEncodeH265Context *enc = avctx->priv_data;
1209
1210 CodedBitstreamContext *cbs;
1211 CodedBitstreamFragment au = { 0 };
1212
1213 err = ff_cbs_init(&cbs, AV_CODEC_ID_HEVC, avctx);
1214 if (err < 0)
1215 return err;
1216
1217 err = ff_cbs_read(cbs, &au, NULL, data, size);
1218 if (err < 0) {
1219 av_log(avctx, AV_LOG_ERROR, "Unable to parse feedback units, bad drivers: %s\n",
1220 av_err2str(err));
1221 goto fail;
1222 }
1223
1224 if (sps_override) {
1225 for (int i = 0; i < au.nb_units; i++) {
1226 if (au.units[i].type == HEVC_NAL_SPS) {
1227 H265RawSPS *sps = au.units[i].content;
1228 enc->units.raw_sps.pic_width_in_luma_samples = sps->pic_width_in_luma_samples;
1229 enc->units.raw_sps.pic_height_in_luma_samples = sps->pic_height_in_luma_samples;
1230 enc->units.raw_sps.log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_luma_coding_block_size;
1231 enc->units.raw_sps.max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter;
1232 enc->units.raw_sps.max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra;
1233 }
1234 }
1235 }
1236
1237 /* If PPS has an override, just copy it entirely. */
1238 if (pps_override) {
1239 for (int i = 0; i < au.nb_units; i++) {
1240 if (au.units[i].type == HEVC_NAL_PPS) {
1241 H265RawPPS *pps = au.units[i].content;
1242 memcpy(&enc->units.raw_pps, pps, sizeof(*pps));
1243 enc->fixed_qp_idr = pps->init_qp_minus26 + 26;
1244 break;
1245 }
1246 }
1247 }
1248
1249 err = 0;
1250fail:
1251 ff_cbs_fragment_free(&au);
1252 ff_cbs_close(&cbs);
1253
1254 return err;
1255}
1256
1257static int init_base_units(AVCodecContext *avctx)
1258{

Callers 1

init_base_unitsFunction · 0.70

Calls 1

av_logFunction · 0.85

Tested by

no test coverage detected