[FFmpeg-devel] [PATCH] ACT demuxer

Michael Niedermayer michaelni
Sun Feb 24 19:36:17 CET 2008


On Sun, Feb 24, 2008 at 09:34:58PM +0600, Vladimir Voroshilov wrote:
> Hi, Reimar
> 
> On Sun, Feb 24, 2008 at 4:56 PM, Reimar D?ffinger
> <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
[...]
> Hopefully attached patch is better.
> 
> 
> -- 
> Regards,
> Vladimir Voroshilov     mailto:voroshil at gmail.com
> JID: voroshil at gmail.com, voroshil at jabber.ru
> ICQ: 95587719

> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 041f224..1118acf 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -14,6 +14,7 @@ HEADERS = avformat.h avio.h rtsp.h rtspcodes.h
>  OBJS-$(CONFIG_AAC_DEMUXER)               += raw.o
>  OBJS-$(CONFIG_AC3_DEMUXER)               += raw.o
>  OBJS-$(CONFIG_AC3_MUXER)                 += raw.o
> +OBJS-$(CONFIG_ACT_DEMUXER)               += act.o
>  OBJS-$(CONFIG_ADTS_MUXER)                += adtsenc.o
>  OBJS-$(CONFIG_AIFF_DEMUXER)              += aiff.o riff.o raw.o
>  OBJS-$(CONFIG_AIFF_MUXER)                += aiff.o riff.o
> diff --git a/libavformat/act.c b/libavformat/act.c
> new file mode 100644
> index 0000000..bcae9c1
> --- /dev/null
> +++ b/libavformat/act.c
> @@ -0,0 +1,150 @@
[...]
> +#include "avformat.h"
> +#include "riff.h"
> +
> +#define CHUNK_SIZE 512
> +#define RIFF_TAG MKTAG('R','I','F','F')
> +#define WAVE_TAG MKTAG('W','A','V','E')
> +
> +typedef struct{
> +    int bytes_left_in_chunk;
> +} ACTContext;
> +

> +static int act_probe(AVProbeData *p)

IMHO a act_ prefix in silly in act.c


> +{
> +    int score=0;
> +
> +    if ((AV_RL32(&p->buf[0]) != RIFF_TAG) ||
> +        (AV_RL32(&p->buf[8]) != WAVE_TAG) ||
> +        (AV_RL32(&p->buf[16]) != 16))
> +    return 0;
> +

> +    if(match_ext(p->filename, "act"))
> +        score=AVPROBE_SCORE_MAX/4;

iam against this, if detection is done based on the filename
then theres no need for act_probe()


> +
> +    if(p->buf_size>256 && p->buf[256]==0x84)
> +        score=AVPROBE_SCORE_MAX;

Please use more than 1 byte + the 1 byte fmt size to detect act
this seperates it from riff wave only by <16bit.


> +
> +    return score;
> +}
> +
> +static int act_read_header(AVFormatContext *s,
> +                           AVFormatParameters *ap)
> +{
> +    ACTContext* ctx = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    int size;
> +    AVStream* st;
> +
> +    int min,sec,msec;
> +
> +    st=av_new_stream(s, 0);
> +    if (!st)
> +        return AVERROR(ENOMEM);
> +
> +    url_fskip(pb, 16);
> +    size=get_le32(pb);
> +    get_wav_header(pb, st->codec, size);
> +
> +    /*
> +      8000Hz (Fine-rec) file format has 10 bytes long
> +      packets with 10ms of sound data in them
> +
> +      Also exists 4400Hz (Long-rec) file format with
> +      11 bytes long packets of 20ms sound data in them.
> +      But since there is no sample iles, this format is not
> +      yet tested.
> +    */

> +    if (st->codec->sample_rate == 4400) {
> +        st->codec->frame_size=11;
> +        av_set_pts_info(st, 64, 20, 1000);
> +    }else if (st->codec->sample_rate == 8000) {
> +        st->codec->frame_size=10;
> +        av_set_pts_info(st, 64, 10, 1000);
> +    }else
> +        return AVERROR_NOFMT;

frame_size is set to invalid values, correct is 80 and 88 IIRC
and
av_set_pts_info(st, 64, st->codec->frame_size, st->codec->sample_rate);



> +
> +    st->codec->codec_id=CODEC_ID_G729A;
> +
> +    url_fseek(pb, 257, SEEK_SET);
> +    msec=get_le16(pb);
> +    sec=get_byte(pb);
> +    min=get_le32(pb);
> +
> +    st->duration=(1000*(min*60+sec)+msec)/st->time_base.num;
> +
> +    ctx->bytes_left_in_chunk=CHUNK_SIZE;
> +
> +    url_fseek(pb, 512, SEEK_SET);
> +
> +    return 0;
> +}
> +
> +
> +static int act_read_packet(AVFormatContext *s,
> +                          AVPacket *pkt)
> +{
> +    ACTContext *ctx = s->priv_data;
> +    ByteIOContext *pb = s->pb;
> +    uint8_t tmp;
> +    int ret;
> +    int frame_size=s->streams[0]->codec->frame_size;

> +    

trailing whitespace


> +    ret=av_get_packet(pb, pkt, frame_size);
> +    if(ret<0)
> +        return ret;
> +    if(ret!=frame_size)
> +        return AVERROR(EIO);
> +
> +    tmp=pkt->data[0];
> +    pkt->data[0]=pkt->data[5];
> +    pkt->data[5]=pkt->data[2];
> +    pkt->data[2]=pkt->data[6];
> +    pkt->data[6]=pkt->data[8];
> +    pkt->data[8]=pkt->data[9];
> +    pkt->data[9]=pkt->data[4];
> +    pkt->data[4]=pkt->data[7];
> +    pkt->data[7]=pkt->data[3];
> +    pkt->data[3]=pkt->data[1];
> +    pkt->data[1]=tmp;

werent there 10 and 11 byte packets, does this work wirth both?


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

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/20080224/61ccc89d/attachment.pgp>



More information about the ffmpeg-devel mailing list