[FFmpeg-soc] [Patch] Maxis EA XA decoder - GSoC Task

Robert Marston rmarston at gmail.com
Sun Apr 13 11:23:53 CEST 2008


On Sun, Apr 13, 2008 at 1:57 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Sun, Apr 13, 2008 at 12:50:30AM +0200, Robert Marston wrote:
>  > On Sat, Apr 12, 2008 at 7:21 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>  > > On Sat, Apr 12, 2008 at 06:12:15PM +0200, Robert Marston wrote:
>  > >  > On Sat, Apr 12, 2008 at 3:00 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>  > >  > >
>  > >  > > On Sat, Apr 12, 2008 at 01:39:45PM +0200, Robert Marston wrote:
>  > >  > >  >
>  > >  > >  > Thanks for pointing that out, I will be the first to admit that my c
>  > >  > >  > knowledge is probably not up to standard when it comes to FFMPEG and
>  > >  > >  > as such would required much feedback from my mentor. I see the GSoC as
>  > >  > >  > good learning opportunity for the myself and a chance to bolster open
>  > >  > >  > source development and potential to increase the code base of the
>  > >  > >  > mentor organizations project.
>  > >  > >  >
>  > >  > >  > Would casting the *(src + channel) to a int32_t stop the above from happening?
>  > >  > >
>  > >  > >  i would put the cast after <<0x1C but before >>shift[channel]
>  > >  > >
>  > >  >
>  > >  > As a matter of interest is that to avoid loosing higher order bits in
>  > >  > the <<0x1C shift?
>  > >
>  > >  no
>  > >
>  >
>  > Sorry that a was a stupid question, the cast would have dropped the
>  > bits anyway. What is the reason for putting the cast after the 0x1C
>  > shift?
>
>  to get the msb into the sign bit
>  just look at these 2 to see the difference on normal x86
>  int x= 0xFFF0;
>  int y= (int16_t)0xFFF0;
>
>
>  [...]
>  > +        for (count1 = 0; count1 < ((buf_size - avctx->channels) / avctx->channels) ; count1++) {
>  > +            for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
>  > +                int32_t sample;
>  > +                for(channel = 0; channel < avctx->channels; channel++) {
>  > +                    sample = (int32_t)(((*(src+channel) >> i) & 0x0F) << 0x1C) >> shift[channel];
>  > +                    sample = (sample +
>
>  > +                             (c->status[channel].sample1 * coeff[channel][0]) +
>  > +                             (c->status[channel].sample2 * coeff[channel][1]) + 0x80) >> 8;
>
>  superflous ()
>
>
>  [...]
>  > +static int xa_probe(AVProbeData *p)
>  > +{
>
>  > +    switch(AV_RL32(&p->buf[0])) {
>
>  this can be written slightly simpler
>
>
>  [...]
>  > +static int xa_read_header(AVFormatContext *s,
>  > +               AVFormatParameters *ap)
>  > +{
>  > +    MaxisXADemuxContext *xa = s->priv_data;
>  > +    ByteIOContext *pb = s->pb;
>  > +    AVStream *st;
>  > +
>  > +    /*Set up the XA Audio Decoder*/
>  > +    st = av_new_stream(s, 0);
>  > +    if (!st)
>  > +        return AVERROR(ENOMEM);
>  > +
>  > +    st->codec->codec_type   = CODEC_TYPE_AUDIO;
>  > +    st->codec->codec_id     = CODEC_ID_ADPCM_EA_MAXIS_XA;
>  > +    url_fskip(pb, 4);       /* Skip the XA ID */
>  > +    xa->out_size            =  get_le32(pb);
>  > +    url_fskip(pb, 2);       /* Skip the tag */
>  > +    st->codec->channels     = get_le16(pb);
>  > +    st->codec->sample_rate  = get_le32(pb);
>  > +    /* Value in file is average byte rate*/
>  > +    st->codec->bit_rate     = get_le32(pb) * 8;
>  > +    st->codec->block_align  = get_le16(pb);
>  > +    st->codec->bits_per_sample = get_le16(pb);
>  > +
>  > +    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
>
>  > +    xa->audio_frame_counter = 0;
>
>  The context is magically initalized to all 0.
>
>  [...]

Corrected above issues, patch attached.

Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: maxis_ea_xa_format.txt
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080413/48b0be57/attachment.txt>


More information about the FFmpeg-soc mailing list