[FFmpeg-devel] [PATCH] Nellymoser 8Khz support within FLV encoder

Benjamin Larsson banan
Fri Oct 17 11:12:31 CEST 2008


Alexander Wichers wrote:
>>> The issue is valid, the patch is most likely ok.
>>
>> i agree, its likely mostly ok but FLV_CODECID_NELLYMOSER_8HZ_MONO why 
>> isnt it 8KHZ?
>>
>
> while I'm at it, here you go...
>
> ------------------------------------------------------------------------
>
> Index: libavformat/flv.h
> ===================================================================
> --- libavformat/flv.h	(revision 15629)
> +++ libavformat/flv.h	(working copy)
> @@ -71,14 +71,14 @@
>  };
>  
>  enum {
> -    FLV_CODECID_PCM                 = 0,
> -    FLV_CODECID_ADPCM               = 1 << FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_MP3                 = 2 << FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_PCM_LE              = 3 << FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_NELLYMOSER_8HZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_NELLYMOSER          = 6 << FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_AAC                 = 10<< FLV_AUDIO_CODECID_OFFSET,
> -    FLV_CODECID_SPEEX               = 11<< FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_PCM                  = 0,
> +    FLV_CODECID_ADPCM                = 1 << FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_MP3                  = 2 << FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_PCM_LE               = 3 << FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_NELLYMOSER_8KHZ_MONO = 5 << FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_NELLYMOSER           = 6 << FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_AAC                  = 10<< FLV_AUDIO_CODECID_OFFSET,
> +    FLV_CODECID_SPEEX                = 11<< FLV_AUDIO_CODECID_OFFSET,
>  };
>  
>  enum {
> Index: libavformat/flvdec.c
> ===================================================================
> --- libavformat/flvdec.c	(revision 15629)
> +++ libavformat/flvdec.c	(working copy)
> @@ -55,7 +55,7 @@
>          case FLV_CODECID_ADPCM: acodec->codec_id = CODEC_ID_ADPCM_SWF;                              break;
>          case FLV_CODECID_SPEEX: acodec->codec_id = CODEC_ID_SPEEX;                                  break;
>          case FLV_CODECID_MP3  : acodec->codec_id = CODEC_ID_MP3      ; astream->need_parsing = AVSTREAM_PARSE_FULL; break;
> -        case FLV_CODECID_NELLYMOSER_8HZ_MONO:
> +        case FLV_CODECID_NELLYMOSER_8KHZ_MONO:
>              acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate
>          case FLV_CODECID_NELLYMOSER:
>              acodec->codec_id = CODEC_ID_NELLYMOSER;
> @@ -384,7 +384,7 @@
>      if(is_audio){
>          if(!st->codec->sample_rate || !st->codec->bits_per_coded_sample || (!st->codec->codec_id && !st->codec->codec_tag)) {
>              st->codec->channels = (flags & FLV_AUDIO_CHANNEL_MASK) == FLV_STEREO ? 2 : 1;
> -            if((flags & FLV_AUDIO_CODECID_MASK) == FLV_CODECID_NELLYMOSER_8HZ_MONO)
> +            if((flags & FLV_AUDIO_CODECID_MASK) == FLV_CODECID_NELLYMOSER_8KHZ_MONO)
>                  st->codec->sample_rate= 8000;
>              else
>                  st->codec->sample_rate = (44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >> FLV_AUDIO_SAMPLERATE_OFFSET) >> 3);
>   

When committed, the last hunk should be a separate commit.

> Index: libavformat/flvenc.c
> ===================================================================
> --- libavformat/flvenc.c	(revision 15629)
> +++ libavformat/flvenc.c	(working copy)
> @@ -103,7 +103,11 @@
>          flags |= FLV_CODECID_ADPCM | FLV_SAMPLESSIZE_16BIT;
>          break;
>      case CODEC_ID_NELLYMOSER:
> -        flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
> +        if (enc->sample_rate == 8000) {
> +            flags |= FLV_CODECID_NELLYMOSER_8KHZ_MONO | FLV_SAMPLESSIZE_16BIT;
> +        } else {
> +            flags |= FLV_CODECID_NELLYMOSER | FLV_SAMPLESSIZE_16BIT;
> +        }
>          break;
>      case 0:
>          flags |= enc->codec_tag<<4;
>   

MvH
Benjamin Larsson






More information about the ffmpeg-devel mailing list