2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "libavutil/avstring.h"
20 #include "libavutil/display.h"
21 #include "libavutil/common.h"
22 #include "libavutil/opt.h"
25 #include "bsf_internal.h"
29 #include "h264_levels.h"
49 typedef struct H264MetadataContext {
52 CodedBitstreamContext *input;
53 CodedBitstreamContext *output;
54 CodedBitstreamFragment access_unit;
60 AVRational sample_aspect_ratio;
62 int overscan_appropriate_flag;
65 int video_full_range_flag;
67 int transfer_characteristics;
68 int matrix_coefficients;
70 int chroma_sample_loc_type;
73 int fixed_frame_rate_flag;
80 const char *sei_user_data;
81 SEIRawUserDataUnregistered sei_user_data_payload;
85 int display_orientation;
88 H264RawSEIDisplayOrientation display_orientation_payload;
91 } H264MetadataContext;
94 static int h264_metadata_update_sps(AVBSFContext *bsf,
97 H264MetadataContext *ctx = bsf->priv_data;
99 int crop_unit_x, crop_unit_y;
101 if (ctx->sample_aspect_ratio.num && ctx->sample_aspect_ratio.den) {
103 static const AVRational sar_idc[] = {
104 { 0, 0 }, // Unspecified (never written here).
105 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
106 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
107 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
108 { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
112 av_reduce(&num, &den, ctx->sample_aspect_ratio.num,
113 ctx->sample_aspect_ratio.den, 65535);
115 for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
116 if (num == sar_idc[i].num &&
117 den == sar_idc[i].den)
120 if (i == FF_ARRAY_ELEMS(sar_idc)) {
121 sps->vui.aspect_ratio_idc = 255;
122 sps->vui.sar_width = num;
123 sps->vui.sar_height = den;
125 sps->vui.aspect_ratio_idc = i;
127 sps->vui.aspect_ratio_info_present_flag = 1;
131 #define SET_VUI_FIELD(field) do { \
132 if (ctx->field >= 0) { \
133 sps->vui.field = ctx->field; \
138 if (ctx->overscan_appropriate_flag >= 0) {
139 SET_VUI_FIELD(overscan_appropriate_flag);
140 sps->vui.overscan_info_present_flag = 1;
143 if (ctx->video_format >= 0 ||
144 ctx->video_full_range_flag >= 0 ||
145 ctx->colour_primaries >= 0 ||
146 ctx->transfer_characteristics >= 0 ||
147 ctx->matrix_coefficients >= 0) {
149 SET_VUI_FIELD(video_format);
151 SET_VUI_FIELD(video_full_range_flag);
153 if (ctx->colour_primaries >= 0 ||
154 ctx->transfer_characteristics >= 0 ||
155 ctx->matrix_coefficients >= 0) {
157 SET_VUI_FIELD(colour_primaries);
158 SET_VUI_FIELD(transfer_characteristics);
159 SET_VUI_FIELD(matrix_coefficients);
161 sps->vui.colour_description_present_flag = 1;
163 sps->vui.video_signal_type_present_flag = 1;
166 if (ctx->chroma_sample_loc_type >= 0) {
167 sps->vui.chroma_sample_loc_type_top_field =
168 ctx->chroma_sample_loc_type;
169 sps->vui.chroma_sample_loc_type_bottom_field =
170 ctx->chroma_sample_loc_type;
171 sps->vui.chroma_loc_info_present_flag = 1;
175 if (ctx->tick_rate.num && ctx->tick_rate.den) {
178 av_reduce(&num, &den, ctx->tick_rate.num, ctx->tick_rate.den,
179 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
181 sps->vui.time_scale = num;
182 sps->vui.num_units_in_tick = den;
184 sps->vui.timing_info_present_flag = 1;
187 SET_VUI_FIELD(fixed_frame_rate_flag);
189 if (sps->separate_colour_plane_flag || sps->chroma_format_idc == 0) {
191 crop_unit_y = 2 - sps->frame_mbs_only_flag;
193 crop_unit_x = 1 + (sps->chroma_format_idc < 3);
194 crop_unit_y = (1 + (sps->chroma_format_idc < 2)) *
195 (2 - sps->frame_mbs_only_flag);
197 #define CROP(border, unit) do { \
198 if (ctx->crop_ ## border >= 0) { \
199 if (ctx->crop_ ## border % unit != 0) { \
200 av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \
201 "must be a multiple of %d.\n", #border, unit); \
202 return AVERROR(EINVAL); \
204 sps->frame_crop_ ## border ## _offset = \
205 ctx->crop_ ## border / unit; \
206 sps->frame_cropping_flag = 1; \
209 CROP(left, crop_unit_x);
210 CROP(right, crop_unit_x);
211 CROP(top, crop_unit_y);
212 CROP(bottom, crop_unit_y);
215 if (ctx->level != LEVEL_UNSET) {
218 if (ctx->level == LEVEL_AUTO) {
219 const H264LevelDescriptor *desc;
221 int width, height, dpb_frames;
224 if (sps->vui.nal_hrd_parameters_present_flag) {
225 bit_rate = (sps->vui.nal_hrd_parameters.bit_rate_value_minus1[0] + 1) *
226 (INT64_C(1) << (sps->vui.nal_hrd_parameters.bit_rate_scale + 6));
227 } else if (sps->vui.vcl_hrd_parameters_present_flag) {
228 bit_rate = (sps->vui.vcl_hrd_parameters.bit_rate_value_minus1[0] + 1) *
229 (INT64_C(1) << (sps->vui.vcl_hrd_parameters.bit_rate_scale + 6));
230 // Adjust for VCL vs. NAL limits.
231 bit_rate = bit_rate * 6 / 5;
236 // Don't use max_dec_frame_buffering if it is only inferred.
237 dpb_frames = sps->vui.bitstream_restriction_flag ?
238 sps->vui.max_dec_frame_buffering : H264_MAX_DPB_FRAMES;
240 width = 16 * (sps->pic_width_in_mbs_minus1 + 1);
241 height = 16 * (sps->pic_height_in_map_units_minus1 + 1) *
242 (2 - sps->frame_mbs_only_flag);
244 if (sps->vui.timing_info_present_flag)
245 framerate = sps->vui.time_scale / sps->vui.num_units_in_tick / 2;
249 desc = ff_h264_guess_level(sps->profile_idc, bit_rate, framerate,
250 width, height, dpb_frames);
252 level_idc = desc->level_idc;
254 av_log(bsf, AV_LOG_WARNING, "Stream does not appear to "
255 "conform to any level: using level 6.2.\n");
259 level_idc = ctx->level;
262 if (level_idc == 9) {
263 if (sps->profile_idc == 66 ||
264 sps->profile_idc == 77 ||
265 sps->profile_idc == 88) {
267 sps->constraint_set3_flag = 1;
272 sps->level_idc = level_idc;
277 sps->vui_parameters_present_flag = 1;
282 static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
284 H264MetadataContext *ctx = bsf->priv_data;
285 CodedBitstreamFragment *au = &ctx->access_unit;
290 side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
295 err = ff_cbs_read(ctx->input, au, side_data, side_data_size);
297 av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n");
301 for (i = 0; i < au->nb_units; i++) {
302 if (au->units[i].type == H264_NAL_SPS) {
303 err = h264_metadata_update_sps(bsf, au->units[i].content);
309 err = ff_cbs_write_fragment_data(ctx->output, au);
311 av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n");
315 side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, au->data_size);
317 return AVERROR(ENOMEM);
318 memcpy(side_data, au->data, au->data_size);
320 ff_cbs_fragment_reset(au);
325 static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
327 H264MetadataContext *ctx = bsf->priv_data;
328 CodedBitstreamFragment *au = &ctx->access_unit;
329 int err, i, j, has_sps;
332 err = ff_bsf_get_packet_ref(bsf, pkt);
336 err = h264_metadata_update_side_data(bsf, pkt);
340 err = ff_cbs_read_packet(ctx->input, au, pkt);
342 av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
346 if (au->nb_units == 0) {
347 av_log(bsf, AV_LOG_ERROR, "No NAL units in packet.\n");
348 err = AVERROR_INVALIDDATA;
352 // If an AUD is present, it must be the first NAL unit.
353 if (au->units[0].type == H264_NAL_AUD) {
354 if (ctx->aud == REMOVE)
355 ff_cbs_delete_unit(au, 0);
357 if (ctx->aud == INSERT) {
358 static const int primary_pic_type_table[] = {
361 0x0e7, // 0, 1, 2, 5, 6, 7
365 0x3bd, // 0, 2, 3, 4, 5, 7, 8, 9
366 0x3ff, // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
368 int primary_pic_type_mask = 0xff;
370 for (i = 0; i < au->nb_units; i++) {
371 if (au->units[i].type == H264_NAL_SLICE ||
372 au->units[i].type == H264_NAL_IDR_SLICE) {
373 H264RawSlice *slice = au->units[i].content;
374 for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++) {
375 if (!(primary_pic_type_table[j] &
376 (1 << slice->header.slice_type)))
377 primary_pic_type_mask &= ~(1 << j);
381 for (j = 0; j < FF_ARRAY_ELEMS(primary_pic_type_table); j++)
382 if (primary_pic_type_mask & (1 << j))
384 if (j >= FF_ARRAY_ELEMS(primary_pic_type_table)) {
385 av_log(bsf, AV_LOG_ERROR, "No usable primary_pic_type: "
386 "invalid slice types?\n");
387 err = AVERROR_INVALIDDATA;
392 .nal_unit_header.nal_unit_type = H264_NAL_AUD,
393 .primary_pic_type = j,
396 err = ff_cbs_insert_unit_content(au,
397 0, H264_NAL_AUD, &aud, NULL);
399 av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
406 for (i = 0; i < au->nb_units; i++) {
407 if (au->units[i].type == H264_NAL_SPS) {
408 err = h264_metadata_update_sps(bsf, au->units[i].content);
415 // Only insert the SEI in access units containing SPSs, and also
416 // unconditionally in the first access unit we ever see.
417 if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
418 err = ff_cbs_sei_add_message(ctx->output, au, 1,
419 SEI_TYPE_USER_DATA_UNREGISTERED,
420 &ctx->sei_user_data_payload, NULL);
422 av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
423 "message to access unit.\n");
428 if (ctx->delete_filler) {
429 for (i = au->nb_units - 1; i >= 0; i--) {
430 if (au->units[i].type == H264_NAL_FILLER_DATA) {
431 ff_cbs_delete_unit(au, i);
436 ff_cbs_sei_delete_message_type(ctx->output, au,
437 SEI_TYPE_FILLER_PAYLOAD);
440 if (ctx->display_orientation != PASS) {
441 SEIRawMessage *message = NULL;
442 while (ff_cbs_sei_find_message(ctx->output, au,
443 SEI_TYPE_DISPLAY_ORIENTATION,
445 H264RawSEIDisplayOrientation *disp = message->payload;
448 matrix = av_malloc(9 * sizeof(int32_t));
450 err = AVERROR(ENOMEM);
454 av_display_rotation_set(matrix,
455 disp->anticlockwise_rotation *
457 av_display_matrix_flip(matrix, disp->hor_flip, disp->ver_flip);
459 // If there are multiple display orientation messages in an
460 // access unit, then the last one added to the packet (i.e.
461 // the first one in the access unit) will prevail.
462 err = av_packet_add_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX,
464 9 * sizeof(int32_t));
466 av_log(bsf, AV_LOG_ERROR, "Failed to attach extracted "
467 "displaymatrix side data to packet.\n");
473 if (ctx->display_orientation == REMOVE ||
474 ctx->display_orientation == INSERT) {
475 ff_cbs_sei_delete_message_type(ctx->output, au,
476 SEI_TYPE_DISPLAY_ORIENTATION);
479 if (ctx->display_orientation == INSERT) {
480 H264RawSEIDisplayOrientation *disp =
481 &ctx->display_orientation_payload;
486 data = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size);
487 if (data && size >= 9 * sizeof(int32_t)) {
492 memcpy(matrix, data, sizeof(matrix));
495 if (matrix[0] < 0 && matrix[4] > 0)
497 else if (matrix[0] > 0 && matrix[4] < 0)
499 av_display_matrix_flip(matrix, hflip, vflip);
501 angle = av_display_rotation_get(matrix);
503 if (!(angle >= -180.0 && angle <= 180.0 /* also excludes NaN */) ||
504 matrix[2] != 0 || matrix[5] != 0 ||
505 matrix[6] != 0 || matrix[7] != 0) {
506 av_log(bsf, AV_LOG_WARNING, "Input display matrix is not "
507 "representable in H.264 parameters.\n");
509 disp->hor_flip = hflip;
510 disp->ver_flip = vflip;
511 disp->anticlockwise_rotation =
512 (uint16_t)rint((angle >= 0.0 ? angle
519 if (has_sps || !ctx->done_first_au) {
520 if (!isnan(ctx->rotate)) {
521 disp->anticlockwise_rotation =
522 (uint16_t)rint((ctx->rotate >= 0.0 ? ctx->rotate
523 : ctx->rotate + 360.0) *
528 disp->hor_flip = !!(ctx->flip & FLIP_HORIZONTAL);
529 disp->ver_flip = !!(ctx->flip & FLIP_VERTICAL);
535 disp->display_orientation_repetition_period = 1;
537 err = ff_cbs_sei_add_message(ctx->output, au, 1,
538 SEI_TYPE_DISPLAY_ORIENTATION,
541 av_log(bsf, AV_LOG_ERROR, "Failed to add display orientation "
542 "SEI message to access unit.\n");
548 err = ff_cbs_write_packet(ctx->output, pkt, au);
550 av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
554 ctx->done_first_au = 1;
558 ff_cbs_fragment_reset(au);
561 av_packet_unref(pkt);
566 static int h264_metadata_init(AVBSFContext *bsf)
568 H264MetadataContext *ctx = bsf->priv_data;
569 CodedBitstreamFragment *au = &ctx->access_unit;
572 if (ctx->sei_user_data) {
573 SEIRawUserDataUnregistered *udu = &ctx->sei_user_data_payload;
576 // Parse UUID. It must be a hex string of length 32, possibly
577 // containing '-'s between hex digits (which we ignore).
578 for (i = j = 0; j < 32 && i < 64 && ctx->sei_user_data[i]; i++) {
580 c = ctx->sei_user_data[i];
583 } else if (av_isxdigit(c)) {
585 v = (c <= '9' ? c - '0' : c - 'a' + 10);
590 udu->uuid_iso_iec_11578[j / 2] |= v;
592 udu->uuid_iso_iec_11578[j / 2] = v << 4;
595 if (j == 32 && ctx->sei_user_data[i] == '+') {
596 udu->data = (uint8_t*)ctx->sei_user_data + i + 1;
597 udu->data_length = strlen(udu->data) + 1;
599 av_log(bsf, AV_LOG_ERROR, "Invalid user data: "
600 "must be \"UUID+string\".\n");
601 err = AVERROR(EINVAL);
606 err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf);
609 err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf);
613 if (bsf->par_in->extradata) {
614 err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
616 av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
620 for (i = 0; i < au->nb_units; i++) {
621 if (au->units[i].type == H264_NAL_SPS) {
622 err = h264_metadata_update_sps(bsf, au->units[i].content);
628 err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
630 av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
637 ff_cbs_fragment_reset(au);
641 static void h264_metadata_close(AVBSFContext *bsf)
643 H264MetadataContext *ctx = bsf->priv_data;
645 ff_cbs_fragment_free(&ctx->access_unit);
646 ff_cbs_close(&ctx->input);
647 ff_cbs_close(&ctx->output);
650 #define OFFSET(x) offsetof(H264MetadataContext, x)
651 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
652 static const AVOption h264_metadata_options[] = {
653 { "aud", "Access Unit Delimiter NAL units",
654 OFFSET(aud), AV_OPT_TYPE_INT,
655 { .i64 = PASS }, PASS, REMOVE, FLAGS, "aud" },
656 { "pass", NULL, 0, AV_OPT_TYPE_CONST,
657 { .i64 = PASS }, .flags = FLAGS, .unit = "aud" },
658 { "insert", NULL, 0, AV_OPT_TYPE_CONST,
659 { .i64 = INSERT }, .flags = FLAGS, .unit = "aud" },
660 { "remove", NULL, 0, AV_OPT_TYPE_CONST,
661 { .i64 = REMOVE }, .flags = FLAGS, .unit = "aud" },
663 { "sample_aspect_ratio", "Set sample aspect ratio (table E-1)",
664 OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL,
665 { .dbl = 0.0 }, 0, 65535, FLAGS },
667 { "overscan_appropriate_flag", "Set VUI overscan appropriate flag",
668 OFFSET(overscan_appropriate_flag), AV_OPT_TYPE_INT,
669 { .i64 = -1 }, -1, 1, FLAGS },
671 { "video_format", "Set video format (table E-2)",
672 OFFSET(video_format), AV_OPT_TYPE_INT,
673 { .i64 = -1 }, -1, 7, FLAGS},
674 { "video_full_range_flag", "Set video full range flag",
675 OFFSET(video_full_range_flag), AV_OPT_TYPE_INT,
676 { .i64 = -1 }, -1, 1, FLAGS },
677 { "colour_primaries", "Set colour primaries (table E-3)",
678 OFFSET(colour_primaries), AV_OPT_TYPE_INT,
679 { .i64 = -1 }, -1, 255, FLAGS },
680 { "transfer_characteristics", "Set transfer characteristics (table E-4)",
681 OFFSET(transfer_characteristics), AV_OPT_TYPE_INT,
682 { .i64 = -1 }, -1, 255, FLAGS },
683 { "matrix_coefficients", "Set matrix coefficients (table E-5)",
684 OFFSET(matrix_coefficients), AV_OPT_TYPE_INT,
685 { .i64 = -1 }, -1, 255, FLAGS },
687 { "chroma_sample_loc_type", "Set chroma sample location type (figure E-1)",
688 OFFSET(chroma_sample_loc_type), AV_OPT_TYPE_INT,
689 { .i64 = -1 }, -1, 6, FLAGS },
691 { "tick_rate", "Set VUI tick rate (num_units_in_tick / time_scale)",
692 OFFSET(tick_rate), AV_OPT_TYPE_RATIONAL,
693 { .dbl = 0.0 }, 0, UINT_MAX, FLAGS },
694 { "fixed_frame_rate_flag", "Set VUI fixed frame rate flag",
695 OFFSET(fixed_frame_rate_flag), AV_OPT_TYPE_INT,
696 { .i64 = -1 }, -1, 1, FLAGS },
698 { "crop_left", "Set left border crop offset",
699 OFFSET(crop_left), AV_OPT_TYPE_INT,
700 { .i64 = -1 }, -1, H264_MAX_WIDTH, FLAGS },
701 { "crop_right", "Set right border crop offset",
702 OFFSET(crop_right), AV_OPT_TYPE_INT,
703 { .i64 = -1 }, -1, H264_MAX_WIDTH, FLAGS },
704 { "crop_top", "Set top border crop offset",
705 OFFSET(crop_top), AV_OPT_TYPE_INT,
706 { .i64 = -1 }, -1, H264_MAX_HEIGHT, FLAGS },
707 { "crop_bottom", "Set bottom border crop offset",
708 OFFSET(crop_bottom), AV_OPT_TYPE_INT,
709 { .i64 = -1 }, -1, H264_MAX_HEIGHT, FLAGS },
711 { "sei_user_data", "Insert SEI user data (UUID+string)",
712 OFFSET(sei_user_data), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = FLAGS },
714 { "delete_filler", "Delete all filler (both NAL and SEI)",
715 OFFSET(delete_filler), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS},
717 { "display_orientation", "Display orientation SEI",
718 OFFSET(display_orientation), AV_OPT_TYPE_INT,
719 { .i64 = PASS }, PASS, EXTRACT, FLAGS, "disp_or" },
720 { "pass", NULL, 0, AV_OPT_TYPE_CONST,
721 { .i64 = PASS }, .flags = FLAGS, .unit = "disp_or" },
722 { "insert", NULL, 0, AV_OPT_TYPE_CONST,
723 { .i64 = INSERT }, .flags = FLAGS, .unit = "disp_or" },
724 { "remove", NULL, 0, AV_OPT_TYPE_CONST,
725 { .i64 = REMOVE }, .flags = FLAGS, .unit = "disp_or" },
726 { "extract", NULL, 0, AV_OPT_TYPE_CONST,
727 { .i64 = EXTRACT }, .flags = FLAGS, .unit = "disp_or" },
729 { "rotate", "Set rotation in display orientation SEI (anticlockwise angle in degrees)",
730 OFFSET(rotate), AV_OPT_TYPE_DOUBLE,
731 { .dbl = NAN }, -360.0, +360.0, FLAGS },
732 { "flip", "Set flip in display orientation SEI",
733 OFFSET(flip), AV_OPT_TYPE_FLAGS,
734 { .i64 = 0 }, 0, FLIP_HORIZONTAL | FLIP_VERTICAL, FLAGS, "flip" },
735 { "horizontal", "Set hor_flip",
736 0, AV_OPT_TYPE_CONST,
737 { .i64 = FLIP_HORIZONTAL }, .flags = FLAGS, .unit = "flip" },
738 { "vertical", "Set ver_flip",
739 0, AV_OPT_TYPE_CONST,
740 { .i64 = FLIP_VERTICAL }, .flags = FLAGS, .unit = "flip" },
742 { "level", "Set level (table A-1)",
743 OFFSET(level), AV_OPT_TYPE_INT,
744 { .i64 = LEVEL_UNSET }, LEVEL_UNSET, 0xff, FLAGS, "level" },
745 { "auto", "Attempt to guess level from stream properties",
746 0, AV_OPT_TYPE_CONST,
747 { .i64 = LEVEL_AUTO }, .flags = FLAGS, .unit = "level" },
748 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
749 { .i64 = value }, .flags = FLAGS, .unit = "level"
752 { LEVEL("1.1", 11) },
753 { LEVEL("1.2", 12) },
754 { LEVEL("1.3", 13) },
756 { LEVEL("2.1", 21) },
757 { LEVEL("2.2", 22) },
759 { LEVEL("3.1", 31) },
760 { LEVEL("3.2", 32) },
762 { LEVEL("4.1", 41) },
763 { LEVEL("4.2", 42) },
765 { LEVEL("5.1", 51) },
766 { LEVEL("5.2", 52) },
768 { LEVEL("6.1", 61) },
769 { LEVEL("6.2", 62) },
775 static const AVClass h264_metadata_class = {
776 .class_name = "h264_metadata_bsf",
777 .item_name = av_default_item_name,
778 .option = h264_metadata_options,
779 .version = LIBAVUTIL_VERSION_INT,
782 static const enum AVCodecID h264_metadata_codec_ids[] = {
783 AV_CODEC_ID_H264, AV_CODEC_ID_NONE,
786 const AVBitStreamFilter ff_h264_metadata_bsf = {
787 .name = "h264_metadata",
788 .priv_data_size = sizeof(H264MetadataContext),
789 .priv_class = &h264_metadata_class,
790 .init = &h264_metadata_init,
791 .close = &h264_metadata_close,
792 .filter = &h264_metadata_filter,
793 .codec_ids = h264_metadata_codec_ids,