[FFmpeg-devel] [PATCH 1/5] lavc: add a table of all codecs names

Michael Niedermayer michaelni at gmx.at
Sun Aug 21 16:05:17 CEST 2011


On Sat, Aug 20, 2011 at 12:02:23PM +0200, Nicolas George wrote:
> Le tridi 3 fructidor, an CCXIX, Michael Niedermayer a écrit :
> > i still think this is overkill but if you want to maintain this,
> > it LGTM and thanks
> 
> It was not just a whim: I have thought it was necessary for a long time. The
> recent discussion only hurried me working on it.
> 
> Here is an updated version of patch #2, using Stefano's
> av_get_media_type_string to further simplify thing and printing the four-cc
> if it exists. It changes slightly the output when the codec is known:
> 
> Stream #0.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 624x352 [PAR 1:...
> Stream #1.0: Video: mpeg4 (Advanced Simple Profile), yuv420p, 352x288 [PAR 1:...
> 
> becomes:
> 
> Stream #0.0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv4...
> Stream #1.0: Video: mpeg4 (Advanced Simple Profile) (FMP4 / 0x34504D46), yuv4...
>                                                     ^^^^^^^^^^^^^^^^^^^
> 
> Regards,
> 
> -- 
>   Nicolas George

>  utils.c |   60 ++++++++++++++++++------------------------------------------
>  1 file changed, 18 insertions(+), 42 deletions(-)
> 16de76746ed4afa3cd175cd210e860cc56593d09  0002-lavc-use-av_get_media_type_string-and-avcodec_get_na.patch
> From 156430779f181e0bc72fec41dbd39dc6f4f87aa3 Mon Sep 17 00:00:00 2001
> From: Nicolas George <nicolas.george at normalesup.org>
> Date: Wed, 17 Aug 2011 15:40:30 +0200
> Subject: [PATCH 2/5] lavc: use av_get_media_type_string and avcodec_get_name
>  in avcodec_string.
> 
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavcodec/utils.c |   60 +++++++++++++++------------------------------------
>  1 files changed, 18 insertions(+), 42 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 1d5ec44..e6e7c42 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1020,43 +1020,35 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta
>  
>  void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
>  {
> +    const char *codec_type;
>      const char *codec_name;
>      const char *profile = NULL;
>      AVCodec *p;
> -    char buf1[32];
>      int bitrate;
>      AVRational display_aspect_ratio;
>  
> -    if (encode)
> -        p = avcodec_find_encoder(enc->codec_id);
> -    else
> -        p = avcodec_find_decoder(enc->codec_id);
> -
> -    if (p) {
> -        codec_name = p->name;
> -        profile = av_get_profile_name(p, enc->profile);
> -    } else if (enc->codec_id == CODEC_ID_MPEG2TS) {
> -        /* fake mpeg2 transport stream codec (currently not
> -           registered) */
> -        codec_name = "mpeg2ts";
> -    } else if (enc->codec_name[0] != '\0') {
> -        codec_name = enc->codec_name;
> -    } else {
> -        /* output avi tags */
> +    codec_type = av_get_media_type_string(enc->codec_type);
> +    codec_name = avcodec_get_name(enc->codec_id);
> +    if (enc->profile != FF_PROFILE_UNKNOWN) {
> +        p = encode ? avcodec_find_encoder(enc->codec_id) : 
> +                     avcodec_find_decoder(enc->codec_id);
> +        if (p)
> +            profile = av_get_profile_name(p, enc->profile);
> +    }
> +
> +    snprintf(buf, buf_size, "%s: %s%s", codec_type ? codec_type : "unknown",
> +             codec_name, enc->mb_decision ? " (hq)" : "");

> +    buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */

this misbehaves when buf_size=0


otherwise LGTM

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- 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/20110821/90f487a8/attachment.asc>


More information about the ffmpeg-devel mailing list