[FFmpeg-devel] [PATCH] ARMovie/RPL demuxer rev6

Michael Niedermayer michaelni
Sun Mar 30 01:05:42 CET 2008


On Sat, Mar 29, 2008 at 03:51:13PM -0700, Eli Friedman wrote:
> Per subject, sixth revision of ARMovie/RPL demuxer.
[...]
> +static int32_t read_int(char* line, char** endptr, int* error)

Line should be const char * and there are others to which this applies
as well.


[...]
> +    error |= read_line(pb, line, sizeof(line));                  // ARMovie
> +    error |= read_line(pb, s->title, sizeof(s->title));          // movie name
> +    error |= read_line(pb, s->copyright, sizeof(s->copyright));  // date/copyright
> +    error |= read_line(pb, s->author, sizeof(s->author));        // author and other

error |= read_line(pb, line        , sizeof(line        ));  // ARMovie
error |= read_line(pb, s->title    , sizeof(s->title    ));  // movie name
error |= read_line(pb, s->copyright, sizeof(s->copyright));  // date/copyright
error |= read_line(pb, s->author   , sizeof(s->author   ));  // author and other


[...]
> +    // Audio headers
> +
> +    // FIXME: ARMovie supports multiple audio tracks; I don't have any
> +    // samples, though. This code will ignore additional tracks.
> +    audio_format = read_line_and_int(pb, &error);  // audio format ID
> +    if (audio_format) {
> +        ast = av_new_stream(s, 0);
> +        if (!ast)
> +            return AVERROR(ENOMEM);
> +        ast->codec->codec_type = CODEC_TYPE_AUDIO;
> +        ast->codec->codec_tag = audio_format;
> +    }
> +
> +    error |= read_line(pb, line, sizeof(line));    // audio bitrate
> +    if (audio_format)
> +        ast->codec->sample_rate = read_int(line, &endptr, &error);
> +
> +    error |= read_line(pb, line, sizeof(line));    // number of audio channels
> +    if (audio_format)
> +        ast->codec->channels = read_int(line, &endptr, &error);
> +
> +    error |= read_line(pb, line, sizeof(line));    // audio bits per sample
> +    if (audio_format) {
> +        ast->codec->bits_per_sample = read_int(line, &endptr, &error);
> +        // At least one sample uses 0 for ADPCM, which is really 4 bits
> +        // per sample.
> +        if (ast->codec->bits_per_sample == 0)
> +            ast->codec->bits_per_sample = 4;
> +    }
> +
> +    // Additional audio fixups
> +    if (audio_format) {
> +        ast->codec->bit_rate = ast->codec->sample_rate *
> +                               ast->codec->bits_per_sample *
> +                               ast->codec->channels;
> +
> +        ast->codec->codec_id = CODEC_ID_NONE;
> +
> +        switch (audio_format) {
> +            case 1:
> +                if (ast->codec->bits_per_sample == 16) {
> +                    // 16-bit audio is always signed
> +                    ast->codec->codec_id = CODEC_ID_PCM_S16LE;
> +                    break;
> +                }
> +                // There are some other formats listed as legal per the spec;
> +                // samples needed.
> +                break;
> +            case 101:
> +                if (ast->codec->bits_per_sample == 8) {
> +                    // The samples with this kind of audio that I have
> +                    // are all unsigned.
> +                    ast->codec->codec_id = CODEC_ID_PCM_U8;
> +                    break;
> +                } else if (ast->codec->bits_per_sample == 4) {
> +                    ast->codec->codec_id = CODEC_ID_ADPCM_IMA_EA_SEAD;
> +                    break;
> +                }
> +                break;
> +        }
> +        if (ast->codec->codec_id == CODEC_ID_NONE) {
> +            av_log(s, AV_LOG_WARNING,
> +                   "RPL audio format %i not supported yet!\n",
> +                   audio_format);
> +        }
> +        av_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
> +    }

all the audio code can be simplified

if(audio_format){
}else
    for(i=0; i<C; i++)
        read_line()

or a

for(i=0; i<C; i++)
    read_line(pb, array[i], ...)
if(audio_format){
    read_int()
    ...
}

or 

...


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080330/9df4b372/attachment.pgp>



More information about the ffmpeg-devel mailing list