[Ffmpeg-devel] THP decoder

Michael Niedermayer michaelni
Thu Apr 5 21:54:54 CEST 2007


Hi

On Thu, Apr 05, 2007 at 09:14:45PM +0400, Kislyakov Maxim wrote:
> Hi,
> I have removed all the floats from adpcm.c. Removed unused structures.
> I got rid of nested structures. Removed code duplications, reformated
> braces. So this is the new patch.


[...]
> +#include "avformat.h"
> +#include "allformats.h"
> +
> +/*THP format description*/
> +typedef struct ThpDemuxerContext  {

comment is still not doxygen compatible


[...]
> +static int thp_probe(AVProbeData *p)
> +{
> +    if (p->buf_size < 4)
> +        return 0;
> +    if (p->buf[0] == 'T' && p->buf[1] == 'H' && p->buf[2] == 'P' && p->buf[3] == '\0') {

still not using simpler AV_RL32(p->buf) and MKTAG


[...]
> +static int thp_read_header(AVFormatContext *s, AVFormatParameters *ap)
> +{
> +    ThpDemuxerContext *thpDemux = s->priv_data;
> +    ByteIOContext *pb = &s->pb;
> +    AVStream *st;
> +    int *header;
> +    get_buffer(pb, header, 4);
> +    if (*header != 0x00504854) {
> +        return AVERROR_NOFMT;
> +    }

this is still wrong


[...]
> +    if (thpDemux->componentTypes[0] == 0) {
> +        st->codec->width = get_be32(pb); /* video width */
> +        st->codec->height = get_be32(pb); /* video height */
> +        if (thpDemux->version == 0x110) {
> +            pb->buf_ptr += 4;
> +        }
> +    }
> +

> +    thpDemux->videoStreamIndex = 0; /* Always should be zero */

useless


> +    st->codec->codec_type = CODEC_TYPE_VIDEO;
> +    st->codec->codec_id = CODEC_ID_THP;
> +    st->codec->codec_tag = 0;  /* no fourcc */

> +    st->codec->sample_rate = av_q2d(thpDemux->fps);

still looks wrong


> +
> +    if (thpDemux->maxAudioSamples != 0) {
> +        st = av_new_stream(s, 0);
> +        if (!st)
> +        {
> +            return AVERROR_NOMEM;
> +        }
> +

> +        thpDemux->audioStreamIndex = 1; /* Always should be one*/

also useless


[...]
> +static inline short adpcm_thp_expand_nibble(ADPCMThpFrameHeader *fh, int8_t nibble,
> +                                            uint8_t index, uint8_t exponent, int st)
> +{
> +    short temp = 0;
> +    signed int factor1;

superflouos signed


[...]
> @@ -1111,6 +1132,49 @@
>              buf_size -= 128;
>          }
>          break;
> +    case CODEC_ID_ADPCM_THP:
> +        src += 8;
> +        int16_t tempCell;

this still breaks gcc 2.95


> +        for (n=0; n<2; n++)  {
> +            for (i=0; i<16; i++)  {
> +                frameHeader->table[n][i] = (src[1] + (src[0] << 8));
> +                src += 2;

bytestream_get_be16()


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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070405/92a81f6f/attachment.pgp>



More information about the ffmpeg-devel mailing list