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
40 40
41#define AUDIO_ID 0xc041#define AUDIO_ID 0xc0
42#define VIDEO_ID 0xe042#define VIDEO_ID 0xe0
43#define H264_ID 0xe2
43#define AC3_ID 0x8044#define AC3_ID 0x80
44#define DTS_ID 0x8a45#define DTS_ID 0x8a
45#define LPCM_ID 0xa046#define LPCM_ID 0xa0
libavformat/mpegenc.c+9−4
@@ -301,7 +301,7 @@ static int get_system_header_size(AVFormatContext *ctx) · 300 unmodified lines
301static av_cold int mpeg_mux_init(AVFormatContext *ctx)301static av_cold int mpeg_mux_init(AVFormatContext *ctx)
302{302{
303 MpegMuxContext *s = ctx->priv_data;303 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;
305 AVStream *st;305 AVStream *st;
306 StreamInfo *stream;306 StreamInfo *stream;
307 int audio_bitrate;307 int audio_bitrate;
@@ -337,6 +337,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 29 unmodified lines
337 ac3_id = AC3_ID;337 ac3_id = AC3_ID;
338 dts_id = DTS_ID;338 dts_id = DTS_ID;
339 mpv_id = VIDEO_ID;339 mpv_id = VIDEO_ID;
340 h264_id = H264_ID;
340 mps_id = SUB_ID;341 mps_id = SUB_ID;
341 lpcm_id = LPCM_ID;342 lpcm_id = LPCM_ID;
342 343
@@ -379,7 +380,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 36 unmodified lines
379 s->audio_bound++;380 s->audio_bound++;
380 break;381 break;
381 case AVMEDIA_TYPE_VIDEO:382 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++;
383 if (st->codec->rc_buffer_size)387 if (st->codec->rc_buffer_size)
384 stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8;388 stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8;
385 else {389 else {
@@ -409,7 +413,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 23 unmodified lines
409 st = ctx->streams[i];413 st = ctx->streams[i];
410 stream = (StreamInfo *)st->priv_data;414 stream = (StreamInfo *)st->priv_data;
411 415
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)
413 codec_rate = st->codec->rc_max_rate;418 codec_rate = st->codec->rc_max_rate;
414 else419 else
415 codec_rate = st->codec->bit_rate;420 codec_rate = st->codec->bit_rate;
@@ -421,7 +426,7 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 5 unmodified lines
421 426
422 if ((stream->id & 0xe0) == AUDIO_ID)427 if ((stream->id & 0xe0) == AUDIO_ID)
423 audio_bitrate += codec_rate;428 audio_bitrate += codec_rate;
424 else if (stream->id == VIDEO_ID)429 else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
425 video_bitrate += codec_rate;430 video_bitrate += codec_rate;
426 }431 }
427 432

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