You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
Support pcm_mulaw in Hikvision CCTV mpeg program streams.
Fixes decoding the sample from videolan trac ticket #8344.
This commit is contained in:
committed by
Michael Niedermayer
parent
7857ddceec
commit
92a9a3020d
@@ -110,6 +110,7 @@ typedef struct MpegDemuxContext {
|
|||||||
unsigned char psm_es_type[256];
|
unsigned char psm_es_type[256];
|
||||||
int sofdec;
|
int sofdec;
|
||||||
int dvd;
|
int dvd;
|
||||||
|
int imkh_cctv;
|
||||||
#if CONFIG_VOBSUB_DEMUXER
|
#if CONFIG_VOBSUB_DEMUXER
|
||||||
AVFormatContext *sub_ctx;
|
AVFormatContext *sub_ctx;
|
||||||
FFDemuxSubtitlesQueue q;
|
FFDemuxSubtitlesQueue q;
|
||||||
@@ -119,22 +120,18 @@ typedef struct MpegDemuxContext {
|
|||||||
static int mpegps_read_header(AVFormatContext *s)
|
static int mpegps_read_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
MpegDemuxContext *m = s->priv_data;
|
MpegDemuxContext *m = s->priv_data;
|
||||||
const char *sofdec = "Sofdec";
|
char buffer[7];
|
||||||
int v, i = 0;
|
|
||||||
int64_t last_pos = avio_tell(s->pb);
|
int64_t last_pos = avio_tell(s->pb);
|
||||||
|
|
||||||
m->header_state = 0xff;
|
m->header_state = 0xff;
|
||||||
s->ctx_flags |= AVFMTCTX_NOHEADER;
|
s->ctx_flags |= AVFMTCTX_NOHEADER;
|
||||||
|
|
||||||
m->sofdec = -1;
|
avio_get_str(s->pb, 6, buffer, sizeof(buffer));
|
||||||
do {
|
if (!memcmp("IMKH", buffer, 4)) {
|
||||||
v = avio_r8(s->pb);
|
m->imkh_cctv = 1;
|
||||||
m->sofdec++;
|
} else if (!memcmp("Sofdec", buffer, 6)) {
|
||||||
} while (v == sofdec[i] && i++ < 6);
|
m->sofdec = 1;
|
||||||
|
} else
|
||||||
m->sofdec = (m->sofdec == 6) ? 1 : 0;
|
|
||||||
|
|
||||||
if (!m->sofdec)
|
|
||||||
avio_seek(s->pb, last_pos, SEEK_SET);
|
avio_seek(s->pb, last_pos, SEEK_SET);
|
||||||
|
|
||||||
/* no need to do more */
|
/* no need to do more */
|
||||||
@@ -506,6 +503,9 @@ static int mpegps_read_packet(AVFormatContext *s,
|
|||||||
} else if(es_type == STREAM_TYPE_AUDIO_AC3){
|
} else if(es_type == STREAM_TYPE_AUDIO_AC3){
|
||||||
codec_id = AV_CODEC_ID_AC3;
|
codec_id = AV_CODEC_ID_AC3;
|
||||||
type = AVMEDIA_TYPE_AUDIO;
|
type = AVMEDIA_TYPE_AUDIO;
|
||||||
|
} else if(m->imkh_cctv && es_type == 0x91){
|
||||||
|
codec_id = AV_CODEC_ID_PCM_MULAW;
|
||||||
|
type = AVMEDIA_TYPE_AUDIO;
|
||||||
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
|
} else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
|
||||||
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
|
static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
|
||||||
unsigned char buf[8];
|
unsigned char buf[8];
|
||||||
@@ -564,6 +564,11 @@ static int mpegps_read_packet(AVFormatContext *s,
|
|||||||
st->id = startcode;
|
st->id = startcode;
|
||||||
st->codec->codec_type = type;
|
st->codec->codec_type = type;
|
||||||
st->codec->codec_id = codec_id;
|
st->codec->codec_id = codec_id;
|
||||||
|
if (st->codec->codec_id == AV_CODEC_ID_PCM_MULAW) {
|
||||||
|
st->codec->channels = 1;
|
||||||
|
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
|
||||||
|
st->codec->sample_rate = 8000;
|
||||||
|
}
|
||||||
st->request_probe = request_probe;
|
st->request_probe = request_probe;
|
||||||
if (codec_id != AV_CODEC_ID_PCM_S16BE)
|
if (codec_id != AV_CODEC_ID_PCM_S16BE)
|
||||||
st->need_parsing = AVSTREAM_PARSE_FULL;
|
st->need_parsing = AVSTREAM_PARSE_FULL;
|
||||||
|
Reference in New Issue
Block a user