&ost->fifo.rptr) == 0) {
ret = avcodec_encode_audio(enc, audio_out, sizeof(audio_out),
(short *)audio_buf);
- s->format->write_packet(s, ost->index, audio_out, ret);
+ s->format->write_packet(s, ost->index, audio_out, ret, 0);
}
} else {
/* output a pcm frame */
}
ret = avcodec_encode_audio(enc, audio_out, size_out,
(short *)buftmp);
- s->format->write_packet(s, ost->index, audio_out, ret);
+ s->format->write_packet(s, ost->index, audio_out, ret, 0);
}
}
default:
return;
}
- s->format->write_packet(s, index, buf, size);
+ s->format->write_packet(s, index, buf, size, 0);
free(buf);
}
ret = avcodec_encode_video(enc,
video_buffer, sizeof(video_buffer),
picture);
- s->format->write_packet(s, ost->index, video_buffer, ret);
+ s->format->write_packet(s, ost->index, video_buffer, ret, 0);
*frame_size = ret;
} else {
write_picture(s, ost->index, picture, enc->pix_fmt, enc->width, enc->height);
codec->sample_rate == icodec->sample_rate &&
codec->channels == icodec->channels) {
/* no reencoding */
+ /* use the same frame size */
+ codec->frame_size = icodec->frame_size;
+ //codec->frame_size = 8*icodec->sample_rate*icodec->frame_size/
+ // icodec->bit_rate;
+ //fprintf(stderr,"\nFrame size: %d", codec->frame_size);
} else {
if (fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE))
goto fail;
}
} else {
/* no reencoding needed : output the packet directly */
- os->format->write_packet(os, ost->index, data_buf, data_size);
+ /* force the input stream PTS */
+ os->format->write_packet(os, ost->index, data_buf, data_size, pkt.pts);
}
}
}
}
} else {
send_it:
- if (av_write_packet(&c->fmt_ctx, &pkt))
+ if (av_write_packet(&c->fmt_ctx, &pkt, 0))
c->state = HTTPSTATE_SEND_DATA_TRAILER;
}
static int asf_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
ASFContext *asf = s->priv_data;
int timestamp;
}
static int audio_write_packet(AVFormatContext *s1, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
AudioData *s = s1->priv_data;
int len, ret;
int (*write_header)(struct AVFormatContext *);
int (*write_packet)(struct AVFormatContext *,
int stream_index,
- unsigned char *buf, int size);
+ unsigned char *buf, int size, int force_pts);
int (*write_trailer)(struct AVFormatContext *);
/* optional input support */
int av_read_packet(AVFormatContext *s, AVPacket *pkt);
void av_close_input_file(AVFormatContext *s);
-int av_write_packet(AVFormatContext *s, AVPacket *pkt);
+int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts);
void dump_format(AVFormatContext *ic,
int index,
}
static int avi_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
AVIContext *avi = s->priv_data;
ByteIOContext *pb = &s->pb;
}
static int ffm_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
AVStream *st = s->streams[stream_index];
FFMStream *fst = st->priv_data;
}
static int img_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
VideoData *img = s->priv_data;
AVStream *st = s->streams[stream_index];
return 0;
}
-static int mpjpeg_write_packet(AVFormatContext *s,
- int stream_index, UINT8 *buf, int size)
+static int mpjpeg_write_packet(AVFormatContext *s, int stream_index,
+ UINT8 *buf, int size, int force_pts)
{
UINT8 buf1[256];
}
static int single_jpeg_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
put_buffer(&s->pb, buf, size);
put_flush_packet(&s->pb);
}
static int jpeg_write_packet(AVFormatContext *s1, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
JpegContext *s = s1->priv_data;
char filename[1024];
stream->start_pts = -1;
}
-static int mpeg_mux_write_packet(AVFormatContext *ctx,
- int stream_index, UINT8 *buf, int size)
+static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index,
+ UINT8 *buf, int size, int force_pts)
{
MpegMuxContext *s = ctx->priv_data;
AVStream *st = ctx->streams[stream_index];
StreamInfo *stream = st->priv_data;
int len;
-
+
while (size > 0) {
/* set pts */
- if (stream->start_pts == -1)
+ if (stream->start_pts == -1) {
+ if (force_pts)
+ stream->pts = force_pts;
stream->start_pts = stream->pts;
+ }
len = s->packet_data_max_size - stream->buffer_ptr;
if (len > size)
len = size;
goto redo;
found:
av_new_packet(pkt, len);
+ //printf("\nRead Packet ID: %x PTS: %f Size: %d", startcode,
+ // (float)pts/90000, len);
get_buffer(&s->pb, pkt->data, pkt->size);
pkt->pts = pts;
pkt->stream_index = i;
int raw_write_packet(struct AVFormatContext *s,
int stream_index,
- unsigned char *buf, int size)
+ unsigned char *buf, int size, int force_pts)
{
put_buffer(&s->pb, buf, size);
put_flush_packet(&s->pb);
}
static int rm_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
if (s->streams[stream_index]->codec.codec_type ==
CODEC_TYPE_AUDIO)
}
static int swf_write_packet(AVFormatContext *s, int stream_index,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
AVCodecContext *codec = &s->streams[stream_index]->codec;
if (codec->codec_type == CODEC_TYPE_AUDIO)
}
-int av_write_packet(AVFormatContext *s, AVPacket *pkt)
+int av_write_packet(AVFormatContext *s, AVPacket *pkt, int force_pts)
{
/* XXX: currently, an emulation because internal API must change */
- return s->format->write_packet(s, pkt->stream_index, pkt->data, pkt->size);
+ return s->format->write_packet(s, pkt->stream_index, pkt->data, pkt->size, force_pts);
}
/* "user interface" functions */
}
static int wav_write_packet(AVFormatContext *s, int stream_index_ptr,
- UINT8 *buf, int size)
+ UINT8 *buf, int size, int force_pts)
{
ByteIOContext *pb = &s->pb;
put_buffer(pb, buf, size);
for(;;) {
clear_blocks(s->block[0]);
+ emms_c();
ret = mpeg_decode_mb(s, s->block);
dprintf("ret=%d\n", ret);
if (ret < 0)
avctx->sample_rate = s->sample_rate;
avctx->channels = s->nb_channels;
avctx->bit_rate = s->bit_rate;
+ avctx->frame_size = s->frame_size;
}
}
}