History

lavf: add "disposition" AVOption to AVStream AVClass

Use it to remove custom disposition parsing code from ffmpeg.c

Anton Khirnov committed 5 years ago

Commit a4c5d241 parent b731fb53 files · +37 −28Browse files

Unified · Split

3 files
  1. doc/APIchanges +1 −0
  2. fftools/ffmpeg.c +12 −28
  3. libavformat/utils.c +24 −0
doc/APIchanges+1−0
@@ -18,6 +18,7 @@ API changes, most recent first: · 17 unmodified lines
18 Add av_stream_get_class(). Schedule adding AVStream.av_class at libavformat18 Add av_stream_get_class(). Schedule adding AVStream.av_class at libavformat
19 major version 60.19 major version 60.
20 Add av_disposition_to_string() and av_disposition_from_string().20 Add av_disposition_to_string() and av_disposition_from_string().
21 Add "disposition" AVOption to AVStream's class.
21 22
222021-11-12 - xxxxxxxxxx - lavu 57.8.100 - hwcontext_vulkan.h232021-11-12 - xxxxxxxxxx - lavu 57.8.100 - hwcontext_vulkan.h
23 Added AVFrame.sem_value, AVVulkanDeviceContext.queue_family_encode_index,24 Added AVFrame.sem_value, AVVulkanDeviceContext.queue_family_encode_index,
fftools/ffmpeg.c+12−28
@@ -3665,34 +3665,18 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, · 3664 unmodified lines
3665 3665
3666 // parse user provided disposition, and update stream values3666 // parse user provided disposition, and update stream values
3667 if (ost->disposition) {3667 if (ost->disposition) {
3668 static const AVOption opts[] = {3668#if LIBAVFORMAT_VERSION_MAJOR >= 60
3669 { "disposition" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },3669 ret = av_opt_set(ost->st, "disposition", ost->disposition, 0);
3670 { "default" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "flags" },3670#else
3671 { "dub" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "flags" },3671 {
3672 { "original" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "flags" },3672 const AVClass *class = av_stream_get_class();
3673 { "comment" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "flags" },3673 const AVOption *o = av_opt_find(&class, "disposition", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ);
3674 { "lyrics" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "flags" },3674
3675 { "karaoke" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "flags" },3675 av_assert0(o);
3676 { "forced" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "flags" },3676 ret = av_opt_eval_flags(&class, o, ost->disposition, &ost->st->disposition);
3677 { "hearing_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "flags" },3677 }
3678 { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "flags" },3678#endif
3679 { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "flags" },3679
3680 { "attached_pic" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC }, .unit = "flags" },
3681 { "captions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "flags" },
3682 { "descriptions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "flags" },
3683 { "dependent" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "flags" },
3684 { "metadata" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "flags" },
3685 { NULL },
3686 };
3687 static const AVClass class = {
3688 .class_name = "",
3689 .item_name = av_default_item_name,
3690 .option = opts,
3691 .version = LIBAVUTIL_VERSION_INT,
3692 };
3693 const AVClass *pclass = &class;
3694
3695 ret = av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
3696 if (ret < 0)3680 if (ret < 0)
3697 return ret;3681 return ret;
3698 }3682 }
libavformat/utils.c+24−0
@@ -722,10 +722,34 @@ void avformat_free_context(AVFormatContext *s) · 721 unmodified lines
722 av_free(s);722 av_free(s);
723}723}
724 724
725static const AVOption stream_options[] = {
726 { "disposition", NULL, offsetof(AVStream, disposition), AV_OPT_TYPE_FLAGS, { .i64 = 0 },
727 .flags = AV_OPT_FLAG_ENCODING_PARAM, .unit = "disposition" },
728 { "default", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "disposition" },
729 { "dub", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "disposition" },
730 { "original", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "disposition" },
731 { "comment", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "disposition" },
732 { "lyrics", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "disposition" },
733 { "karaoke", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "disposition" },
734 { "forced", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "disposition" },
735 { "hearing_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "disposition" },
736 { "visual_impaired", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "disposition" },
737 { "clean_effects", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "disposition" },
738 { "attached_pic", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ATTACHED_PIC }, .unit = "disposition" },
739 { "timed_thumbnails", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_TIMED_THUMBNAILS }, .unit = "disposition" },
740 { "captions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "disposition" },
741 { "descriptions", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "disposition" },
742 { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
743 { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
744 { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
745 { NULL }
746};
747
725static const AVClass stream_class = {748static const AVClass stream_class = {
726 .class_name = "AVStream",749 .class_name = "AVStream",
727 .item_name = av_default_item_name,750 .item_name = av_default_item_name,
728 .version = LIBAVUTIL_VERSION_INT,751 .version = LIBAVUTIL_VERSION_INT,
752 .option = stream_options,
729};753};
730 754
731const AVClass *av_stream_get_class(void)755const AVClass *av_stream_get_class(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t