* [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
@ 2023-12-18 19:19 Anton Khirnov
2023-12-18 19:19 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_demux: set discard on the AVStream directly Anton Khirnov
2023-12-18 19:30 ` [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption James Almer
0 siblings, 2 replies; 8+ messages in thread
From: Anton Khirnov @ 2023-12-18 19:19 UTC (permalink / raw)
To: ffmpeg-devel
---
libavformat/options.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavformat/options.c b/libavformat/options.c
index bf6113ca95..cc89dd6c72 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
{ "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
{ "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
{ "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
+
+ { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
+ .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
+ { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
+ { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
+ { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
+ { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
+ { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
+ { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
+ { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
{ NULL }
};
--
2.42.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_demux: set discard on the AVStream directly
2023-12-18 19:19 [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption Anton Khirnov
@ 2023-12-18 19:19 ` Anton Khirnov
2023-12-18 19:30 ` [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption James Almer
1 sibling, 0 replies; 8+ messages in thread
From: Anton Khirnov @ 2023-12-18 19:19 UTC (permalink / raw)
To: ffmpeg-devel
Avoid taking an ugly detour through the decoder AVCodecContext.
---
fftools/ffmpeg_demux.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index eca3de709c..a28a94b5ed 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1141,7 +1141,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
ist->reinit_filters = -1;
MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
- MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
ist->user_set_discard = AVDISCARD_NONE;
if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
@@ -1150,20 +1149,20 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
(o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA))
ist->user_set_discard = AVDISCARD_ALL;
- ist->dec_ctx = avcodec_alloc_context3(ist->dec);
- if (!ist->dec_ctx)
- return AVERROR(ENOMEM);
-
+ MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
if (discard_str) {
- const AVOption *discard_opt = av_opt_find(ist->dec_ctx, "skip_frame",
- NULL, 0, 0);
- ret = av_opt_eval_int(ist->dec_ctx, discard_opt, discard_str, &ist->user_set_discard);
+ ret = av_opt_set(ist->st, "discard", discard_str, 0);
if (ret < 0) {
av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str);
return ret;
}
+ ist->user_set_discard = ist->st->discard;
}
+ ist->dec_ctx = avcodec_alloc_context3(ist->dec);
+ if (!ist->dec_ctx)
+ return AVERROR(ENOMEM);
+
ret = avcodec_parameters_to_context(ist->dec_ctx, par);
if (ret < 0) {
av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");
--
2.42.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-18 19:19 [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption Anton Khirnov
2023-12-18 19:19 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_demux: set discard on the AVStream directly Anton Khirnov
@ 2023-12-18 19:30 ` James Almer
2023-12-19 10:41 ` Anton Khirnov
1 sibling, 1 reply; 8+ messages in thread
From: James Almer @ 2023-12-18 19:30 UTC (permalink / raw)
To: ffmpeg-devel
On 12/18/2023 4:19 PM, Anton Khirnov wrote:
> ---
> libavformat/options.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/libavformat/options.c b/libavformat/options.c
> index bf6113ca95..cc89dd6c72 100644
> --- a/libavformat/options.c
> +++ b/libavformat/options.c
> @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
> { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
> { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
> { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
> +
> + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
> + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
> + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
> + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
> + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
> + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
> + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
> + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
> + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
> { NULL }
> };
Should be ok.
Maybe also add "id" like i did for AVStreamGroup while at it.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-18 19:30 ` [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption James Almer
@ 2023-12-19 10:41 ` Anton Khirnov
2023-12-19 12:09 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Anton Khirnov @ 2023-12-19 10:41 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting James Almer (2023-12-18 20:30:47)
> On 12/18/2023 4:19 PM, Anton Khirnov wrote:
> > ---
> > libavformat/options.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/libavformat/options.c b/libavformat/options.c
> > index bf6113ca95..cc89dd6c72 100644
> > --- a/libavformat/options.c
> > +++ b/libavformat/options.c
> > @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
> > { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
> > { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
> > { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
> > +
> > + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
> > + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
> > + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
> > + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
> > + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
> > + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
> > + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
> > + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
> > + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
> > { NULL }
> > };
>
> Should be ok.
>
> Maybe also add "id" like i did for AVStreamGroup while at it.
The problem with id is how to flag it - it's read-only for demuxing and
user-settable for muxing.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-19 10:41 ` Anton Khirnov
@ 2023-12-19 12:09 ` James Almer
2023-12-19 12:10 ` Anton Khirnov
0 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2023-12-19 12:09 UTC (permalink / raw)
To: ffmpeg-devel
On 12/19/2023 7:41 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-12-18 20:30:47)
>> On 12/18/2023 4:19 PM, Anton Khirnov wrote:
>>> ---
>>> libavformat/options.c | 10 ++++++++++
>>> 1 file changed, 10 insertions(+)
>>>
>>> diff --git a/libavformat/options.c b/libavformat/options.c
>>> index bf6113ca95..cc89dd6c72 100644
>>> --- a/libavformat/options.c
>>> +++ b/libavformat/options.c
>>> @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
>>> { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
>>> { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
>>> { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
>>> +
>>> + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
>>> + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
>>> + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
>>> + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
>>> + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
>>> + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
>>> + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
>>> + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
>>> + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
>>> { NULL }
>>> };
>>
>> Should be ok.
>>
>> Maybe also add "id" like i did for AVStreamGroup while at it.
>
> The problem with id is how to flag it - it's read-only for demuxing and
> user-settable for muxing.
Wouldn't the AV_OPT_FLAG_ENCODING_PARAM flag be enough for the CLI to
reject it for demuxing cases?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-19 12:09 ` James Almer
@ 2023-12-19 12:10 ` Anton Khirnov
2023-12-20 3:02 ` James Almer
0 siblings, 1 reply; 8+ messages in thread
From: Anton Khirnov @ 2023-12-19 12:10 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting James Almer (2023-12-19 13:09:05)
> On 12/19/2023 7:41 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-12-18 20:30:47)
> >> On 12/18/2023 4:19 PM, Anton Khirnov wrote:
> >>> ---
> >>> libavformat/options.c | 10 ++++++++++
> >>> 1 file changed, 10 insertions(+)
> >>>
> >>> diff --git a/libavformat/options.c b/libavformat/options.c
> >>> index bf6113ca95..cc89dd6c72 100644
> >>> --- a/libavformat/options.c
> >>> +++ b/libavformat/options.c
> >>> @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
> >>> { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
> >>> { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
> >>> { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
> >>> +
> >>> + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
> >>> + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
> >>> + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
> >>> + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
> >>> + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
> >>> + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
> >>> + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
> >>> + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
> >>> + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
> >>> { NULL }
> >>> };
> >>
> >> Should be ok.
> >>
> >> Maybe also add "id" like i did for AVStreamGroup while at it.
> >
> > The problem with id is how to flag it - it's read-only for demuxing and
> > user-settable for muxing.
>
> Wouldn't the AV_OPT_FLAG_ENCODING_PARAM flag be enough for the CLI to
> reject it for demuxing cases?
Those flags should be set for all callers, not just the CLI. And for
demuxing the proper flag is AV_OPT_FLAG_EXPORT
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-19 12:10 ` Anton Khirnov
@ 2023-12-20 3:02 ` James Almer
2023-12-22 10:38 ` Anton Khirnov
0 siblings, 1 reply; 8+ messages in thread
From: James Almer @ 2023-12-20 3:02 UTC (permalink / raw)
To: ffmpeg-devel
On 12/19/2023 9:10 AM, Anton Khirnov wrote:
> Quoting James Almer (2023-12-19 13:09:05)
>> On 12/19/2023 7:41 AM, Anton Khirnov wrote:
>>> Quoting James Almer (2023-12-18 20:30:47)
>>>> On 12/18/2023 4:19 PM, Anton Khirnov wrote:
>>>>> ---
>>>>> libavformat/options.c | 10 ++++++++++
>>>>> 1 file changed, 10 insertions(+)
>>>>>
>>>>> diff --git a/libavformat/options.c b/libavformat/options.c
>>>>> index bf6113ca95..cc89dd6c72 100644
>>>>> --- a/libavformat/options.c
>>>>> +++ b/libavformat/options.c
>>>>> @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
>>>>> { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
>>>>> { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
>>>>> { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
>>>>> +
>>>>> + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
>>>>> + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
>>>>> + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
>>>>> + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
>>>>> + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
>>>>> + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
>>>>> + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
>>>>> + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
>>>>> + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
>>>>> { NULL }
>>>>> };
>>>>
>>>> Should be ok.
>>>>
>>>> Maybe also add "id" like i did for AVStreamGroup while at it.
>>>
>>> The problem with id is how to flag it - it's read-only for demuxing and
>>> user-settable for muxing.
>>
>> Wouldn't the AV_OPT_FLAG_ENCODING_PARAM flag be enough for the CLI to
>> reject it for demuxing cases?
>
> Those flags should be set for all callers, not just the CLI. And for
Of course, but by flagging it as AV_OPT_FLAG_ENCODING_PARAM any caller,
CLI included, can make sure to not attempt to set it on demuxing scenarios.
> demuxing the proper flag is AV_OPT_FLAG_EXPORT
Agree, that flag should be set too for id.
I don't think ENCODING_PARAM and EXPORT are incompatible. The doxy for
the former states "a generic parameter which can be set by the user for
muxing or encoding" and for the latter "The option is intended for
exporting values to the caller", which fulfills both of the requirements
you listed above: The caller can't set it on demuxing scenarios but can
read it to see what a demuxer wrote to it, and can both set it on muxing
scenarios and look at what a muxer may have written on it.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption
2023-12-20 3:02 ` James Almer
@ 2023-12-22 10:38 ` Anton Khirnov
0 siblings, 0 replies; 8+ messages in thread
From: Anton Khirnov @ 2023-12-22 10:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting James Almer (2023-12-20 04:02:37)
> On 12/19/2023 9:10 AM, Anton Khirnov wrote:
> > Quoting James Almer (2023-12-19 13:09:05)
> >> On 12/19/2023 7:41 AM, Anton Khirnov wrote:
> >>> Quoting James Almer (2023-12-18 20:30:47)
> >>>> On 12/18/2023 4:19 PM, Anton Khirnov wrote:
> >>>>> ---
> >>>>> libavformat/options.c | 10 ++++++++++
> >>>>> 1 file changed, 10 insertions(+)
> >>>>>
> >>>>> diff --git a/libavformat/options.c b/libavformat/options.c
> >>>>> index bf6113ca95..cc89dd6c72 100644
> >>>>> --- a/libavformat/options.c
> >>>>> +++ b/libavformat/options.c
> >>>>> @@ -229,6 +229,16 @@ static const AVOption stream_options[] = {
> >>>>> { "metadata", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "disposition" },
> >>>>> { "dependent", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEPENDENT }, .unit = "disposition" },
> >>>>> { "still_image", .type = AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_STILL_IMAGE }, .unit = "disposition" },
> >>>>> +
> >>>>> + { "discard", NULL, offsetof(AVStream, discard), AV_OPT_TYPE_INT, { .i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX,
> >>>>> + .flags = AV_OPT_FLAG_DECODING_PARAM, .unit = "avdiscard" },
> >>>>> + { "none", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, .unit = "avdiscard" },
> >>>>> + { "default", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, .unit = "avdiscard" },
> >>>>> + { "noref", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, .unit = "avdiscard" },
> >>>>> + { "bidir", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, .unit = "avdiscard" },
> >>>>> + { "nointra", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA }, .unit = "avdiscard" },
> >>>>> + { "nokey", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, .unit = "avdiscard" },
> >>>>> + { "all", .type = AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, .unit = "avdiscard" },
> >>>>> { NULL }
> >>>>> };
> >>>>
> >>>> Should be ok.
> >>>>
> >>>> Maybe also add "id" like i did for AVStreamGroup while at it.
> >>>
> >>> The problem with id is how to flag it - it's read-only for demuxing and
> >>> user-settable for muxing.
> >>
> >> Wouldn't the AV_OPT_FLAG_ENCODING_PARAM flag be enough for the CLI to
> >> reject it for demuxing cases?
> >
> > Those flags should be set for all callers, not just the CLI. And for
>
> Of course, but by flagging it as AV_OPT_FLAG_ENCODING_PARAM any caller,
> CLI included, can make sure to not attempt to set it on demuxing scenarios.
>
> > demuxing the proper flag is AV_OPT_FLAG_EXPORT
>
> Agree, that flag should be set too for id.
>
> I don't think ENCODING_PARAM and EXPORT are incompatible. The doxy for
> the former states "a generic parameter which can be set by the user for
> muxing or encoding" and for the latter "The option is intended for
> exporting values to the caller", which fulfills both of the requirements
> you listed above: The caller can't set it on demuxing scenarios but can
> read it to see what a demuxer wrote to it, and can both set it on muxing
> scenarios and look at what a muxer may have written on it.
Setting both makes the flags useless. The entire point of
AV_OPT_FLAG_EXPORT is to allow the caller to generically identify
options whose values are meant to be read rather than set. If it cannot
be used for that purpose, then why have it at all?
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-22 10:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 19:19 [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption Anton Khirnov
2023-12-18 19:19 ` [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg_demux: set discard on the AVStream directly Anton Khirnov
2023-12-18 19:30 ` [FFmpeg-devel] [PATCH 1/2] lavf: allow setting AVStream.discard as an AVOption James Almer
2023-12-19 10:41 ` Anton Khirnov
2023-12-19 12:09 ` James Almer
2023-12-19 12:10 ` Anton Khirnov
2023-12-20 3:02 ` James Almer
2023-12-22 10:38 ` Anton Khirnov
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git