[FFmpeg-devel] [PATCH] oma demuxer

Benjamin Larsson banan
Tue Jun 3 18:57:32 CEST 2008


Michael Niedermayer wrote:
> On Fri, May 30, 2008 at 02:09:35PM +0200, Benjamin Larsson wrote:
>> Michael Niedermayer wrote:
>>> On Sat, May 24, 2008 at 03:55:23PM +0200, Benjamin Larsson wrote:
>>>> Michael Niedermayer wrote:
>>>>> On Sat, May 24, 2008 at 04:51:10AM +0200, Benjamin Larsson wrote:
>>>>>> Michael Niedermayer wrote:
>>>>> [...]
>>> [...]
>>>>>> }
>>>>>>
>>>>>>
>>>>>> static void get_atrac3_info(const uint8_t *buf, int *frame_size, int *mode, int *sample_rate)
>>>>>> {
>>>>> AVCodecContext could be passed as arg instead of these dozen pointers.
>>>>>
>>>> Well there is no context left.
>>> there still is AVCodecContext, really, you are storing things in it :)
> 
> well you can also remove get_atrac3_info() completely and inline the code if you
> prefer.
> 

Inlined.

> 
> [...]
>> static int is_ea3_tag_header(const uint8_t *buf)
>> {
>>     return (!memcmp(buf, (uint8_t[]){'e', 'a', '3', 3, 0},5));
>> }
> 
> i think it would be cleaner to replace the single use of this by the
> actual code
> 

Inlined.

> 
> [...]
>>     /* decode sample rate */
>>     switch ((info >> 13) & 7) {
>>         case 0:
>>             *sample_rate = 32000;
>>             break;
>>         case 1:
>>             *sample_rate = 44100;
>>             break;
>>         case 2:
>>             *sample_rate = 48000;
>>             break;
>>         default:
>>             *sample_rate = 0;
>>     }
>> }
> [...]
>>     /* get the atrac3 codec parameters */
>>     get_atrac3_info(buf, &framesize, &jsflag, &samplerate);
>>     if (samplerate != 44100) {
>>         av_log(s, AV_LOG_INFO, "Unsupported sample rate, send sample file to developers: %d\n", samplerate);
>>         return -1;
>>     }
> 
> if(((info >> 13) & 7) != 2) {
>     ...
> }
> st->codec->sample_rate= 44100;
> 

I reworked the code to handle atrac3+ demuxing also.

> 
>>     /* try to detect atrac3 mode using framesize */
>>     switch (framesize) {
>>         case 192: bit_rate=66000;  break;
>>         case 272: bit_rate=94000;  break;
>>         case 304: bit_rate=105000; break;
>>         case 384: bit_rate=132000; break;
>>         default:
>>             av_log(s, AV_LOG_INFO, "Invalid frame size: %d\n", framesize);
>>             return -1;
>>     }
> 
> these numbers contradict themselfs
> bit_rate= sample_rate * framesize * 8 / 1024
> 
> we do not need a switch to set false values.
> 

Indeed, fixed.

> 
> [...]
>> static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
>> {
>>     int ret, size;
>>
>>     size = s->streams[0]->codec->block_align;
>>
>>     ret= av_get_packet(s->pb, pkt, size);
> 
> the size variable is redundant.

Fixed.

> 
> 
>>     pkt->stream_index = 0;
>>     if (ret <= 0) {
>>         return AVERROR(EIO);
>>     }
> 
> superflous {}

Fixed.

> 
> 
>>     return ret;
>> }
>>
> 
>> static int oma_read_seek(AVFormatContext *s,
>>                          int stream_index, int64_t timestamp, int flags)
>> {
>>     return pcm_read_seek(s, stream_index, timestamp, flags);
>> }
> 
> you can use pcm_read_seek below directly if above is correct

Fixed.

MvH
Benjamin Larsson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: oma.c
Type: text/x-csrc
Size: 6885 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080603/9d4b8cb5/attachment.c>



More information about the ffmpeg-devel mailing list