Ticket #7804: codec_tag.patch

File codec_tag.patch, 1.6 KB (added by thfisher@…, 14 years ago)

Patch to improve setting of codec_type.

  • libs/libavformat/mpegts.c

     
    2929#include <pthread.h>
    3030#include "mpegts.h"
    3131#include "internal.h"
     32#include "riff.h"
    3233
    3334/* 1.0 second at 24Mbit/s */
    3435#define MAX_SCAN_PACKETS 32000
     
    617618    }
    618619}
    619620
     621
    620622static AVStream *new_pes_av_stream(PESContext *pes, uint32_t prog_reg_desc, uint32_t code)
    621623{
     624static const AVCodecTag mpeg_stream_tags[] = {
     625        { STREAM_TYPE_VIDEO_MPEG1,              MKTAG('m', 'p', 'g', '1') },
     626        { STREAM_TYPE_VIDEO_MPEG2,              MKTAG('m', 'p', 'g', '2') },
     627        { STREAM_TYPE_VIDEO_MPEG4,              MKTAG('M', 'P', 'G', '4') },
     628        { STREAM_TYPE_VIDEO_H264,               MKTAG('H', '2', '6', '4') },
     629        { STREAM_TYPE_VIDEO_VC1,                MKTAG('W', 'V', 'C', '1') },
     630        { STREAM_TYPE_VIDEO_DIRAC,              MKTAG('d', 'r', 'a', 'c') },
     631        { 0, 0 }
     632    };
    622633    AVStream *st = av_new_stream(pes->stream, pes->pid);
     634    uint idx;
    623635
    624636    if (!st)
    625637        return NULL;
     
    634646    dprintf(pes->stream, "stream_type=%x pid=%x prog_reg_desc=%.4s\n",
    635647            pes->stream_type, pes->pid, (char*)&prog_reg_desc);
    636648
    637     st->codec->codec_tag = pes->stream_type;
     649//    st->codec->codec_tag = pes->stream_type;
     650    for (idx = 0; mpeg_stream_tags[idx].id && mpeg_stream_tags[idx].id != pes->stream_type; idx++ )
     651    {
     652    }
     653    st->codec->codec_tag = mpeg_stream_tags[idx].tag;
    638654
    639655    mpegts_find_stream_type(st, pes->stream_type, ISO_types);
    640656    if (prog_reg_desc == AV_RL32("HDMV") &&