History

mpeg: Write H264 streams at offset 2

It hints that the content is H264 according to HD-DVD.

Luca Barbato committed 12 years ago

Commit 4e9e6fa1 parent a4d3c202 files · +10 −4Browse files

Unified · Split

2 files
  1. libavformat/mpeg.h +1 −0
  2. libavformat/mpegenc.c +9 −4
libavformat/mpeg.h+1−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040
4141 #define AUDIO_ID 0xc0
4242 #define VIDEO_ID 0xe0
43+#define H264_ID 0xe2
4344 #define AC3_ID 0x80
4445 #define DTS_ID 0x8a
4546 #define LPCM_ID 0xa0
libavformat/mpegenc.c+9−4
@@ -301,7 +301,7 @@ static int get_system_header_size(AVFormatContext *ctx) · 300 unmodified lines
301301 static av_cold int mpeg_mux_init(AVFormatContext *ctx)
302302 {
303303 MpegMuxContext *s = ctx->priv_data;
304− int bitrate, i, mpa_id, mpv_id, mps_id, ac3_id, dts_id, lpcm_id, j;
304+ int bitrate, i, mpa_id, mpv_id, h264_id, mps_id, ac3_id, dts_id, lpcm_id, j;
305305 AVStream *st;
306306 StreamInfo *stream;
307307 int audio_bitrate;
@@ -337,6 +337,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 29 unmodified lines
337337 ac3_id = AC3_ID;
338338 dts_id = DTS_ID;
339339 mpv_id = VIDEO_ID;
340+ h264_id = H264_ID;
340341 mps_id = SUB_ID;
341342 lpcm_id = LPCM_ID;
342343
@@ -379,7 +380,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 36 unmodified lines
379380 s->audio_bound++;
380381 break;
381382 case AVMEDIA_TYPE_VIDEO:
382− stream->id = mpv_id++;
383+ if (st->codec->codec_id == AV_CODEC_ID_H264)
384+ stream->id = h264_id++;
385+ else
386+ stream->id = mpv_id++;
383387 if (st->codec->rc_buffer_size)
384388 stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8;
385389 else {
@@ -409,7 +413,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 23 unmodified lines
409413 st = ctx->streams[i];
410414 stream = (StreamInfo *)st->priv_data;
411415
412− if (st->codec->rc_max_rate || stream->id == VIDEO_ID)
416+ if (st->codec->rc_max_rate ||
417+ st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
413418 codec_rate = st->codec->rc_max_rate;
414419 else
415420 codec_rate = st->codec->bit_rate;
@@ -421,7 +426,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 5 unmodified lines
421426
422427 if ((stream->id & 0xe0) == AUDIO_ID)
423428 audio_bitrate += codec_rate;
424− else if (stream->id == VIDEO_ID)
429+ else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
425430 video_bitrate += codec_rate;
426431 }
427432

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t