[FFmpeg-devel] [PATCH] oma demuxer

Benjamin Larsson banan
Fri May 30 14:09:35 CEST 2008


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 :)
> 
> 
> [...]
>>>
>>>>     /* get framesize */
>>>>     /* soundUnit * 4 * nChannels */
>>>>     *frame_size = (info & 0x3FF) * 8;
>>> the *8 could be moved to where block_align is inited, this would also allow
>>> uint8_t to be used i the table ...
>>>
>> Fixed. But everything is now obfuscated, before it was possible to
>> understand the table by looking at it.
> 
> we could write 192/8 and such in the table?

Rewrote.

> 
> 
>>>>     /* get coding mode */
>>>>     *mode = (info >> 17) & 1;
>>>>
>>>>     /* 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;
>>> ff_ac3_sample_rate_tab could be used here
>>>
>> It's in the wrong order and 3 bits=6 elements can overflow the table. In
>> the future there might be other sample rates.
> 
> i meant
> 
> case 0:
> case 1:
> case 2:
>     *sample_rate = ff_ac3_sample_rate_tab[ ...
> 
> 
> but anyway leave it, its becoming too messy
> 

Ok.

> 
> [...]
> 
>> static struct {
>>     uint8_t    bitrate;
> 
> kbitrate
> 

Rewrote.

> 
>>     uint8_t    framesize;
>>     uint8_t    coding_mode;
>> }  atrac3_modes[5] = {
>>     {66,  24, 1},
>>     {94,  34, 1},
>>     {105, 38, 0},
>>     {132, 48, 0},
>>     {  0,  0, 0},
>> };
>>
>>
> 

Rewrote.


>> static int is_ea3_tag_header(const uint8_t *buf)
>> {
>>     return (!memcmp(buf, "ea3", 3) && buf[3] == 3 && buf[4] == 0);
>> }
> 
> i meant
> 
> s/is_ea3_tag_header(buf)/memcmp(buf, (uint8_t[]){'e', 'a', '3', 3, 0})/
> 

Fixed.

> 
> [...]
>>     /* check the EA3 header */
>>     if (strncmp(buf, "EA3", 3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
>>         av_log(s, AV_LOG_INFO, "Couldn't find the EA3 header !\n");
>>         return -1;
>>     }
> 
> could use memcmp() too
> 

Added.

> 
> 
> 
>>     /* try to detect atrac3 mode using framesize */
>>     for (mode=0 ; mode<5 ; mode++) {
> 
> mode<4 and the table does not need a 5th 0,0,0 entry

Rewritten.

Added seeking support also.

MvH
Benjamin Larsson

-------------- next part --------------
A non-text attachment was scrubbed...
Name: oma.c
Type: text/x-csrc
Size: 6792 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080530/1d48f2a5/attachment.c>



More information about the ffmpeg-devel mailing list