[FFmpeg-devel] [PATCH 2/4] lavd: add device capabilities API
Michael Niedermayer
michaelni at gmx.at
Sun Feb 16 13:24:38 CET 2014
On Sun, Feb 16, 2014 at 12:45:20PM +0100, Nicolas George wrote:
> Le tridi 23 pluviôse, an CCXXII, Lukasz M a écrit :
> > It is shared in different structs.
>
> And unshared in, at least, AVCodecContext. But that does not matter much.
>
> > >
> > > > +
> > > > + /**
> > > > + * Initialize device capabilities submodule.
> > > > + * @see avdevice_capabilities_create() for more details.
> > > > + */
> > > > + int (*create_device_capabilities)(struct AVFormatContext *s, void
> > > *caps);
> > > > +
> > > > + /**
> > > > + * Apply currently set device capabilities to device context.
> > > > + * @see avdevice_capabilities_apply() for more details.
> > > > + */
> > > > + int (*apply_device_capabilities)(struct AVFormatContext *s, void
> > > *caps,
> > > > + int strategy);
> > > > +
> > > > + /**
> > > > + * Free device capabilities submodule.
> > > > + * @see avdevice_capabilities_free() for more details.
> > > > + */
> > > > + int (*free_device_capabilities)(struct AVFormatContext *s, void
> > > *caps);
> > >
> > > Would it make sense to share these between in and out formats?
> > >
> >
> > Hmmm, I don't understand how?
>
> Instead of having the three fields create_device_capabilities,
> apply_device_capabilities and free_device_capabilities in both AVInputFormat
> and AVOutputFormat, you could just declare a single structure
> AVDeviceQueryMethods with these three fields, and add a pointer to it in
> both AVInputFormat and AVOutputFormat.
>
> That was just a random thought.
>
> >
> >
> > Updated patch attached
>
> > From 5db27e54528f64ebf36519311d4c95648228f1b3 Mon Sep 17 00:00:00 2001
> > From: Lukasz Marek <lukasz.m.luki at gmail.com>
> > Date: Fri, 7 Feb 2014 14:35:01 +0100
> > Subject: [PATCH 2/4] lavd: add device capabilities API
> >
> > TODO: bump minors, update APIchages
> >
> > Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> > ---
> > libavdevice/avdevice.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++
> > libavdevice/avdevice.h | 79 ++++++++++++++++++++++++++++++++++++++
> > libavformat/avformat.h | 36 +++++++++++++++++
> > 3 files changed, 215 insertions(+)
> >
> > diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c
> > index 92cb834..c3f8ea4 100644
> > --- a/libavdevice/avdevice.c
> > +++ b/libavdevice/avdevice.c
> > @@ -17,9 +17,50 @@
> > */
> >
> > #include "libavutil/avassert.h"
> > +#include "libavcodec/avcodec.h"
> > #include "avdevice.h"
> > #include "config.h"
> >
> > +#define E AV_OPT_FLAG_ENCODING_PARAM
> > +#define D AV_OPT_FLAG_DECODING_PARAM
> > +#define A AV_OPT_FLAG_AUDIO_PARAM
> > +#define V AV_OPT_FLAG_VIDEO_PARAM
> > +#define OFFSET(x) offsetof(AVDeviceCapabilitiesQuery, x)
> > +
> > +const AVOption av_device_capabilities[] = {
> > + { "device_name", "device name", OFFSET(device_name), AV_OPT_TYPE_STRING,
> > + {.str = NULL}, 0, 0, E|D|A|V },
> > + { "codec", "codec", OFFSET(codec), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|A|V },
> > + { "format", "format", OFFSET(format), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|A|V },
> > +
> > + { "sample_rate", "sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|A },
> > + { "channels", "channels", OFFSET(channels), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|A },
> > + { "channel_layout", "channel layout", OFFSET(channel_layout), AV_OPT_TYPE_INT64,
> > + {.i64 = -1}, -1, INT_MAX, E|D|A },
> > +
> > + { "window_width", "window width", OFFSET(window_width), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|V },
> > + { "window_height", "window height", OFFSET(window_height), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|V },
>
> > + { "frame_width", "frame width", OFFSET(frame_width), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|V },
> > + { "frame_height", "frame height", OFFSET(frame_height), AV_OPT_TYPE_INT,
> > + {.i64 = -1}, -1, INT_MAX, E|D|V },
>
> This version still has one open issue: how does it express a limited set of
> frame sizes. For example, if a webcam supports exactly 640×480 and 320×240.
> Does it return { 320, 640 } for the width and { 240, 480 } for the height?
> Is the application supposed to try each width in turn and query the
> corresponding range for height? It works, although it is a bit cumbersome,
> but it is not intuitive: maybe add a comment, or do it like that in the
> examples.
maybe AV_OPT_TYPE_IMAGE_SIZE, should be used
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140216/9c7b802a/attachment.asc>
More information about the ffmpeg-devel
mailing list