move packetheader after startcodes
Originally committed as revision 2215 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
99b17f25b1
commit
ed0bb7bee6
@ -217,10 +217,9 @@ static int nut_write_header(AVFormatContext *s)
|
|||||||
stream_length = s->streams[i]->duration * (AV_TIME_BASE / 1000);
|
stream_length = s->streams[i]->duration * (AV_TIME_BASE / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
put_packetheader(nut, bc, 120);
|
|
||||||
|
|
||||||
/* main header */
|
/* main header */
|
||||||
put_be64(bc, MAIN_STARTCODE);
|
put_be64(bc, MAIN_STARTCODE);
|
||||||
|
put_packetheader(nut, bc, 120);
|
||||||
put_v(bc, 0); /* version */
|
put_v(bc, 0); /* version */
|
||||||
put_v(bc, s->nb_streams);
|
put_v(bc, s->nb_streams);
|
||||||
put_v(bc, 0); /* file size */
|
put_v(bc, 0); /* file size */
|
||||||
@ -234,8 +233,8 @@ static int nut_write_header(AVFormatContext *s)
|
|||||||
{
|
{
|
||||||
codec = &s->streams[i]->codec;
|
codec = &s->streams[i]->codec;
|
||||||
|
|
||||||
put_packetheader(nut, bc, 120);
|
|
||||||
put_be64(bc, STREAM_STARTCODE);
|
put_be64(bc, STREAM_STARTCODE);
|
||||||
|
put_packetheader(nut, bc, 120);
|
||||||
put_v(bc, i /*s->streams[i]->index*/);
|
put_v(bc, i /*s->streams[i]->index*/);
|
||||||
put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
|
put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
|
||||||
if (codec->codec_tag)
|
if (codec->codec_tag)
|
||||||
@ -285,9 +284,9 @@ static int nut_write_header(AVFormatContext *s)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* info header */
|
/* info header */
|
||||||
|
put_be64(bc, INFO_STARTCODE);
|
||||||
put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+
|
put_packetheader(nut, bc, 16+strlen(s->author)+strlen(s->title)+
|
||||||
strlen(s->comment)+strlen(s->copyright));
|
strlen(s->comment)+strlen(s->copyright));
|
||||||
put_be64(bc, INFO_STARTCODE);
|
|
||||||
if (s->author[0])
|
if (s->author[0])
|
||||||
{
|
{
|
||||||
put_v(bc, 5); /* type */
|
put_v(bc, 5); /* type */
|
||||||
@ -339,8 +338,6 @@ static int nut_write_packet(AVFormatContext *s, int stream_index,
|
|||||||
if (enc->codec_type == CODEC_TYPE_VIDEO)
|
if (enc->codec_type == CODEC_TYPE_VIDEO)
|
||||||
key_frame = enc->coded_frame->key_frame;
|
key_frame = enc->coded_frame->key_frame;
|
||||||
|
|
||||||
put_packetheader(nut, bc, size+(key_frame?8:0)+20);
|
|
||||||
|
|
||||||
if (key_frame)
|
if (key_frame)
|
||||||
put_be64(bc, KEYFRAME_STARTCODE);
|
put_be64(bc, KEYFRAME_STARTCODE);
|
||||||
|
|
||||||
@ -352,6 +349,8 @@ static int nut_write_packet(AVFormatContext *s, int stream_index,
|
|||||||
flags<<=1; flags|=0; //reserved
|
flags<<=1; flags|=0; //reserved
|
||||||
|
|
||||||
put_byte(bc, flags);
|
put_byte(bc, flags);
|
||||||
|
|
||||||
|
put_packetheader(nut, bc, size+20);
|
||||||
put_v(bc, stream_index);
|
put_v(bc, stream_index);
|
||||||
put_s(bc, force_pts); /* lsb_timestamp */
|
put_s(bc, force_pts); /* lsb_timestamp */
|
||||||
update_packetheader(nut, bc, size);
|
update_packetheader(nut, bc, size);
|
||||||
@ -374,8 +373,8 @@ static int nut_write_trailer(AVFormatContext *s)
|
|||||||
|
|
||||||
for (i = 0; s->nb_streams; i++)
|
for (i = 0; s->nb_streams; i++)
|
||||||
{
|
{
|
||||||
put_packetheader(nut, bc, 64);
|
|
||||||
put_be64(bc, INDEX_STARTCODE);
|
put_be64(bc, INDEX_STARTCODE);
|
||||||
|
put_packetheader(nut, bc, 64);
|
||||||
put_v(bc, s->streams[i]->id);
|
put_v(bc, s->streams[i]->id);
|
||||||
put_v(bc, ...);
|
put_v(bc, ...);
|
||||||
put_be32(bc, 0); /* FIXME: checksum */
|
put_be32(bc, 0); /* FIXME: checksum */
|
||||||
@ -412,10 +411,10 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
int cur_stream, nb_streams;
|
int cur_stream, nb_streams;
|
||||||
|
|
||||||
/* main header */
|
/* main header */
|
||||||
get_packetheader(nut, bc);
|
|
||||||
tmp = get_be64(bc);
|
tmp = get_be64(bc);
|
||||||
if (tmp != MAIN_STARTCODE)
|
if (tmp != MAIN_STARTCODE)
|
||||||
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
|
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
|
||||||
|
get_packetheader(nut, bc);
|
||||||
|
|
||||||
tmp = get_v(bc);
|
tmp = get_v(bc);
|
||||||
if (tmp != 0)
|
if (tmp != 0)
|
||||||
@ -436,10 +435,10 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
|
|||||||
int class;
|
int class;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
|
|
||||||
get_packetheader(nut, bc);
|
|
||||||
tmp = get_be64(bc);
|
tmp = get_be64(bc);
|
||||||
if (tmp != STREAM_STARTCODE)
|
if (tmp != STREAM_STARTCODE)
|
||||||
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
|
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
|
||||||
|
get_packetheader(nut, bc);
|
||||||
st = av_new_stream(s, get_v(bc));
|
st = av_new_stream(s, get_v(bc));
|
||||||
if (!st)
|
if (!st)
|
||||||
return AVERROR_NOMEM;
|
return AVERROR_NOMEM;
|
||||||
@ -508,7 +507,6 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
int key_frame = 0;
|
int key_frame = 0;
|
||||||
uint64_t tmp;
|
uint64_t tmp;
|
||||||
|
|
||||||
get_packetheader(nut, bc);
|
|
||||||
|
|
||||||
if (url_feof(bc))
|
if (url_feof(bc))
|
||||||
return -1;
|
return -1;
|
||||||
@ -527,6 +525,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
else
|
else
|
||||||
fprintf(stderr, "error in zero bit / startcode %LX\n", tmp);
|
fprintf(stderr, "error in zero bit / startcode %LX\n", tmp);
|
||||||
}
|
}
|
||||||
|
get_packetheader(nut, bc);
|
||||||
#if 0
|
#if 0
|
||||||
if (((tmp & 0x60)>>5) > 3) /* priority <= 3 */
|
if (((tmp & 0x60)>>5) > 3) /* priority <= 3 */
|
||||||
fprintf(stderr, "sanity check failed!\n");
|
fprintf(stderr, "sanity check failed!\n");
|
||||||
@ -573,7 +572,7 @@ static AVOutputFormat nut_oformat = {
|
|||||||
#elif defined(CONFIG_MP3LAME)
|
#elif defined(CONFIG_MP3LAME)
|
||||||
CODEC_ID_MP3LAME,
|
CODEC_ID_MP3LAME,
|
||||||
#else
|
#else
|
||||||
CODEC_ID_AC3,
|
CODEC_ID_MP2, /* AC3 needs liba52 decoder */
|
||||||
#endif
|
#endif
|
||||||
CODEC_ID_MPEG4,
|
CODEC_ID_MPEG4,
|
||||||
nut_write_header,
|
nut_write_header,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user