if (st->codec.codec_id == CODEC_ID_PCM_S16BE && samp_sz == 8) st->codec.codec_id = CODEC_ID_PCM_S8;
static int parse_stsd(const MOVParseTableEntry *parse_table, ByteIOContext *pb, uint32_t atom_type, int64_t atom_offset, int64_t atom_size, void *param){    MOVContext *c;    int entries, size, samp_sz, frames_per_sample, id;    uint32_t format;    AVStream *st;    MOVStreamContext *sc;#ifdef DEBUG    print_atom("stsd", atom_type, atom_offset, atom_size);#endif    c = (MOVContext *)param;    st = c->fc->streams[c->fc->nb_streams-1];    sc = (MOVStreamContext *)st->priv_data;    get_byte(pb); /* version */    get_byte(pb); get_byte(pb); get_byte(pb); /* flags */    entries = get_be32(pb);    while(entries--) {        size = get_be32(pb); /* size */        format = get_le32(pb); /* data format */                get_be32(pb); /* reserved */        get_be16(pb); /* reserved */        get_be16(pb); /* index */        /* for MPEG4: set codec type by looking for it */        id = codec_get_id(mov_video_tags, format);        if (id >= 0) {            AVCodec *codec;            codec = avcodec_find_decoder(id);            if (codec)                st->codec.codec_type = codec->type;        }#ifdef DEBUG        printf("size=%d 4CC= %c%c%c%c codec_type=%d\n",                size,                (format >> 0) & 0xff,               (format >> 8) & 0xff,               (format >> 16) & 0xff,               (format >> 24) & 0xff,               st->codec.codec_type);#endif        if(st->codec.codec_type==CODEC_TYPE_VIDEO) {            st->codec.codec_tag = format;            st->codec.codec_id = codec_get_id(mov_video_tags, format);            get_be16(pb); /* version */            get_be16(pb); /* revision level */            get_be32(pb); /* vendor */            get_be32(pb); /* temporal quality */            get_be32(pb); /* spacial quality */            st->codec.width = get_be16(pb); /* width */            st->codec.height = get_be16(pb); /* height */#if 1            if (st->codec.codec_id == CODEC_ID_MPEG4) {                /* in some MPEG4 the width/height are not correct, so                   we ignore this info */                st->codec.width = 0;                st->codec.height = 0;            }#endif            get_be32(pb); /* horiz resolution */            get_be32(pb); /* vert resolution */            get_be32(pb); /* data size, always 0 */            frames_per_sample = get_be16(pb); /* frame per samples */#ifdef DEBUG	    printf("frames/samples = %d\n", frames_per_sample);#endif            url_fskip(pb, 32); /* codec name */            get_be16(pb); /* depth */            get_be16(pb); /* colortable id */                        st->codec.frame_rate      = 25;            st->codec.frame_rate_base = 1;                        size -= (16+8*4+2+32+2*2);            while (size >= 8) {                int atom_size, atom_type;                int64_t start_pos;                                atom_size = get_be32(pb);                atom_type = get_le32(pb);                size -= 8;#ifdef DEBUG                printf("VIDEO: atom_type=%c%c%c%c atom_size=%d size_left=%d\n",                        (atom_type >> 0) & 0xff,                       (atom_type >> 8) & 0xff,                       (atom_type >> 16) & 0xff,                       (atom_type >> 24) & 0xff,                       atom_size, size);#endif                start_pos = url_ftell(pb);                switch(atom_type) {                case MKTAG('e', 's', 'd', 's'):                    {                        int tag, len;                        /* Well, broken but suffisant for some MP4 streams */                        get_be32(pb); /* version + flags */                        len = mp4_read_descr(pb, &tag);                        if (tag == 0x03) {                            /* MP4ESDescrTag */                            get_be16(pb); /* ID */                            get_byte(pb); /* priority */                            len = mp4_read_descr(pb, &tag);                            if (tag != 0x04)                                goto fail;                            /* MP4DecConfigDescrTag */                            get_byte(pb); /* objectTypeId */                            get_be32(pb); /* streamType + buffer size */                            get_be32(pb); /* max bit rate */                            get_be32(pb); /* avg bit rate */                            len = mp4_read_descr(pb, &tag);                            if (tag != 0x05)                                goto fail;                            /* MP4DecSpecificDescrTag */#ifdef DEBUG                            printf("Specific MPEG4 header len=%d\n", len);#endif                            sc->header_data = av_mallocz(len);                            if (sc->header_data) {                                get_buffer(pb, sc->header_data, len);                                sc->header_len = len;                            }                        }                        /* in any case, skip garbage */                    }                    break;                default:                    break;                }            fail:                url_fskip(pb, (atom_size - 8) -                           ((url_ftell(pb) - start_pos)));                size -= atom_size - 8;            }            if (size > 0) {                /* unknown extension */                url_fskip(pb, size);            }        } else {            st->codec.codec_tag = format;            get_be16(pb); /* version */            get_be16(pb); /* revision level */            get_be32(pb); /* vendor */            st->codec.channels = get_be16(pb);/* channel count */            samp_sz = get_be16(pb); /* sample size */#ifdef DEBUG            if(samp_sz != 16)                puts("!!! stsd: audio sample size is not 16 bit !");#endif                        st->codec.codec_id = codec_get_id(mov_audio_tags, format);            /* handle specific s8 codec */            if (st->codec.codec_id == CODEC_ID_PCM_S16BE && samp_sz == 8)            st->codec.codec_id = CODEC_ID_PCM_S8;            get_be16(pb); /* compression id = 0*/            get_be16(pb); /* packet size = 0 */                        st->codec.sample_rate = ((get_be32(pb) >> 16));            st->codec.bit_rate = 0;#if 0            get_be16(pb); get_be16(pb); /*  */            get_be16(pb); /*  */            get_be16(pb); /*  */            get_be16(pb); /*  */            get_be16(pb); /*  */#endif                        if(size > 16)                url_fskip(pb, size-(16+20));        }    }/*    if(len) {    buf = av_malloc(len+1);        get_buffer(pb, buf, len);        buf[len] = '\0';        puts(buf);        av_free(buf);    }*/    return 0;}