[FFmpeg-devel] [PATCH] QCELP decoder

Kenan Gillet kenan.gillet
Mon Nov 3 07:29:51 CET 2008


Hi,
On Oct 30, 2008, at 3:39 PM, Michael Niedermayer wrote:

>>>>
>>>> +}
>>>> +
>>>> +/*
>>>> + * Determine the framerate from the frame size and/or the first
>>>> byte of the frame.
>>>> + *
>>>> + * @return 0 on success, negative error number otherwise.
>>>> + */
>>>> +static int determine_framerate(AVCodecContext *avctx,
>>>> +                               QCELPContext *q,
>>>> +                               const int buf_size,
>>>> +                               uint8_t **buf) {
>>>> +    int claimed_rate = -1;
>>>> +
>>>> +    switch (buf_size) {
>>>> +    case 35: claimed_rate = RATE_FULL;
>>>> +    case 34: q->framerate = RATE_FULL;
>>>> +             break;
>>>> +
>>>> +    case 17: claimed_rate = RATE_HALF;
>>>> +    case 16: q->framerate = RATE_HALF;
>>>> +             break;
>>>> +
>>>> +    case  8: claimed_rate = RATE_QUARTER;
>>>> +    case  7: q->framerate = RATE_QUARTER;
>>>> +             break;
>>>> +
>>>> +    case  4: claimed_rate = RATE_OCTAVE;
>>>> +    case  3: q->framerate = RATE_OCTAVE;
>>>> +             break;
>>>> +
>>>> +    case  1: claimed_rate = SILENCE;
>>>> +    case  0: q->framerate = SILENCE;
>>>> +             break;
>>>> +
>>>> +    default:
>>>> +        return -1;
>>>> +    }
>>>> +
>>>> +    if (claimed_rate >= 0) {
>>>> +        q->framerate = *(*buf)++;
>>>> +
>>>> +        if (claimed_rate != q->framerate)
>>>> +            av_log(avctx, AV_LOG_WARNING, "Claimed framerate and
>>>> buffer size mismatch.\n");
>>>> +    } else
>>>> +        av_log(avctx, AV_LOG_WARNING,
>>>> +               "Framerate byte is missing, guessing the framerate
>>>> from packet size.\n");
>>>> +
>>>
>>> putting a switch for 34,16,7,3,0 in a seperate function the
>>> following could
>>> be used:
>>>
>>> q->framerate= foo(buf_size);
>>> if(q->framerate < 0){
>>>   q->framerate = *(*buf)++;
>>>
>>>   if (foo(buf_size+1) != q->framerate)
>>>       av_log(avctx, AV_LOG_WARNING, "Claimed framerate and buffer
>>> size mismatch.\n");
>>> }else{
>>>
>>> ...
>>>
>>
>> done, use 35, 17,8, 4 and 1 because it is much more probable that the
>> buffer contains a framerate byte.
>> Actually, I have never seen any files where the framerate byte is
>> missing; I just kept this check because
>> it was in the SOC code.
>
>> Should I remove it ? or keep it ?
>
> hmmmmm
> do what you prefer ...

Reynaldo,

Have you seen any QCELP frames where the byte rate is missing?

Kenan






More information about the ffmpeg-devel mailing list