[FFmpeg-devel] [PATCH 2/2] ADP demuxer

James Almer jamrial at gmail.com
Sun Apr 21 00:35:30 CEST 2013


On 20/04/13 5:01 PM, Michael Niedermayer wrote:
> On Sat, Apr 20, 2013 at 12:03:21AM -0300, James Almer wrote:
>>
>> +typedef struct ADPDemuxContext {
>> +    int64_t    filesize;
>> +} ADPDemuxContext;
>> +
>> +static int adp_probe(AVProbeData *p)
>> +{
>> +    if (p->buf[0] == p->buf[2] && p->buf[1] == p->buf[3])
>> +        return AVPROBE_SCORE_MAX / 3;
>> +    return 0;
>> +}
> 
> does this pass tools/probetest ?
> 
> also if there are multiple adpcm "packets" then more could maybe be
> checked

It doesn't fail probetest. And sure, i can do that.
It will solve the conflict with tiertex i mentioned before as well.

>> +
>> +static int adp_read_header(AVFormatContext *s)
>> +{
>> +    ADPDemuxContext *adp = s->priv_data;
>> +    AVStream *st;
>> +
>> +    st = avformat_new_stream(s, NULL);
>> +    if (!st)
>> +        return AVERROR(ENOMEM);
>> +
>> +    adp->filesize = avio_size(s->pb);
>> +    st->codec->codec_type     = AVMEDIA_TYPE_AUDIO;
>> +    st->codec->codec_id       = AV_CODEC_ID_ADPCM_DTK;
>> +    st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
>> +    st->codec->channels       = 2;
>> +    st->codec->sample_rate    = 48000;
>> +    st->start_time            = 0;
>> +    st->duration              = adp->filesize / 32 * 28;
>> +
>> +    avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
>> +
>> +    return 0;
>> +}
>> +
>> +static int adp_read_packet(AVFormatContext *s, AVPacket *pkt)
>> +{
>> +    ADPDemuxContext *adp = s->priv_data;
>> +    int ret, size = FFMIN(adp->filesize, 32 * 1024);
> 
> this will fail with pipes and things where a filesize cannot be
> determined

Would a check for s->pb->seekable be enough to know if filesize can be determined? Or do you think 
it's better to simply remove the filesize check and always try to fetch 1024 or so bytes?
Afaik, the only case where that FFMIN check would be useful is when the file is broken (So it discards the
packet). Otherwise they are always multiple of 1024.

Regards.


More information about the ffmpeg-devel mailing list