Re: [FFmpeg-devel] [PATCH] dump: show audio service type
L'octidi 18 ventôse, an CCXXIII, Thomas Volkert a écrit : We could add const char *av_get_audio_service_name(enum AVAudioServiceType type) to avutil.h and use this function both in avformat and avfilter. In the short term, that would probably be the best (although I would slightly prefer if the function name was based on the full DeCamelCased name of the type, i.e. av_get_audio_service_type_name(), but that is not very important). For the longer term, I have started to try a more generic approach, but before wasting time on something that can not work, I would like to know if the following works on all supported platforms, including as shared library with a crappy linker: lavu/something.h: extern struct Foo foo_constants; lavu/something.c: struct Foo foo_constants; lavc/something.c: AVOption dummy = { .default_val = {.str=foo_constants} }; In other words: initializing a pointer field in a structure with the address of an object in another library. If someone knows, especially if someone knows it does not work, that would be very useful. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] dump: show audio service type
On Sun, Mar 08, 2015 at 11:56:34AM +0100, Thomas Volkert wrote: --- libavformat/dump.c | 29 + 1 file changed, 29 insertions(+) diff --git a/libavformat/dump.c b/libavformat/dump.c index 56b37ff..9801042 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -291,6 +291,31 @@ static void dump_stereo3d(void *ctx, AVPacketSideData *sd) av_log(ctx, AV_LOG_INFO, (inverted)); } +static void dump_audio_service_type(void *ctx, AVPacketSideData *sd) +{ +enum AVAudioServiceType *ast; + +if (sd-size sizeof(*ast)) { +av_log(ctx, AV_LOG_INFO, invalid data); +return; +} + +ast = (enum AVAudioServiceType *)sd-data; + +switch (*ast) { +case AV_AUDIO_SERVICE_TYPE_MAIN: av_log(ctx, AV_LOG_INFO, Main Audio Service); break; +case AV_AUDIO_SERVICE_TYPE_EFFECTS: av_log(ctx, AV_LOG_INFO, Effects);break; +case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, AV_LOG_INFO, Visually Impaired); break; +case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: av_log(ctx, AV_LOG_INFO, Hearing Impaired); break; +case AV_AUDIO_SERVICE_TYPE_DIALOGUE: av_log(ctx, AV_LOG_INFO, Dialogue); break; +case AV_AUDIO_SERVICE_TYPE_COMMENTARY:av_log(ctx, AV_LOG_INFO, Commentary); break; +case AV_AUDIO_SERVICE_TYPE_EMERGENCY: av_log(ctx, AV_LOG_INFO, Emergency); break; +case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:av_log(ctx, AV_LOG_INFO, Voice Over); break; +case AV_AUDIO_SERVICE_TYPE_KARAOKE: av_log(ctx, AV_LOG_INFO, Karaoke);break; +default: av_log(ctx, AV_LOG_INFO, unknown);break; +} +} + static void dump_sidedata(void *ctx, AVStream *st, const char *indent) { int i; @@ -328,6 +353,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) av_log(ctx, AV_LOG_INFO, stereo3d: ); dump_stereo3d(ctx, sd); break; +case AV_PKT_DATA_AUDIO_SERVICE_TYPE: +av_log(ctx, AV_LOG_INFO, audio svc type : ); +dump_audio_service_type(ctx, sd); +break; default: av_log(ctx, AV_LOG_WARNING, unknown side data type %d (%d bytes), sd.type, sd.size); Factorize it with ashowinfo instead of copying the code. You can add a public helper returning the string. -- Clément B. pgp1f_FpsdxVd.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] dump: show audio service type
--- libavformat/dump.c | 29 + 1 file changed, 29 insertions(+) diff --git a/libavformat/dump.c b/libavformat/dump.c index 56b37ff..9801042 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -291,6 +291,31 @@ static void dump_stereo3d(void *ctx, AVPacketSideData *sd) av_log(ctx, AV_LOG_INFO, (inverted)); } +static void dump_audio_service_type(void *ctx, AVPacketSideData *sd) +{ +enum AVAudioServiceType *ast; + +if (sd-size sizeof(*ast)) { +av_log(ctx, AV_LOG_INFO, invalid data); +return; +} + +ast = (enum AVAudioServiceType *)sd-data; + +switch (*ast) { +case AV_AUDIO_SERVICE_TYPE_MAIN: av_log(ctx, AV_LOG_INFO, Main Audio Service); break; +case AV_AUDIO_SERVICE_TYPE_EFFECTS: av_log(ctx, AV_LOG_INFO, Effects);break; +case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, AV_LOG_INFO, Visually Impaired); break; +case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: av_log(ctx, AV_LOG_INFO, Hearing Impaired); break; +case AV_AUDIO_SERVICE_TYPE_DIALOGUE: av_log(ctx, AV_LOG_INFO, Dialogue); break; +case AV_AUDIO_SERVICE_TYPE_COMMENTARY:av_log(ctx, AV_LOG_INFO, Commentary); break; +case AV_AUDIO_SERVICE_TYPE_EMERGENCY: av_log(ctx, AV_LOG_INFO, Emergency); break; +case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:av_log(ctx, AV_LOG_INFO, Voice Over); break; +case AV_AUDIO_SERVICE_TYPE_KARAOKE: av_log(ctx, AV_LOG_INFO, Karaoke);break; +default: av_log(ctx, AV_LOG_INFO, unknown);break; +} +} + static void dump_sidedata(void *ctx, AVStream *st, const char *indent) { int i; @@ -328,6 +353,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) av_log(ctx, AV_LOG_INFO, stereo3d: ); dump_stereo3d(ctx, sd); break; +case AV_PKT_DATA_AUDIO_SERVICE_TYPE: +av_log(ctx, AV_LOG_INFO, audio svc type : ); +dump_audio_service_type(ctx, sd); +break; default: av_log(ctx, AV_LOG_WARNING, unknown side data type %d (%d bytes), sd.type, sd.size); -- 2.1.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] dump: show audio service type
On 03/08/2015 12:03 PM, Nicolas George wrote: L'octidi 18 ventôse, an CCXXIII, Clement Boesch a écrit : Factorize it with ashowinfo instead of copying the code. You can add a public helper returning the string. I strongly support the second option. All enums like that should have a corresponding string - enum utility. Actually, we may want to make this kind of string - enum mapping more standard, so they can be used in options parsing, but that is more work, so not necessary immediately. We could add const char *av_get_audio_service_name(enum AVAudioServiceType type) to avutil.h and use this function both in avformat and avfilter. Best regards, Thomas. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] dump: show audio service type
L'octidi 18 ventôse, an CCXXIII, Clement Boesch a écrit : Factorize it with ashowinfo instead of copying the code. You can add a public helper returning the string. I strongly support the second option. All enums like that should have a corresponding string - enum utility. Actually, we may want to make this kind of string - enum mapping more standard, so they can be used in options parsing, but that is more work, so not necessary immediately. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel