AVFormatContext *os;
AVOutputStream *ost;
int ret, i;
- uint8_t *data_buf;
- int data_size, got_picture;
+ int got_picture;
AVFrame picture;
void *buffer_to_free;
static unsigned int samples_size= 0;
//while we have more to decode or while the decoder did output something on EOF
while (avpkt.size > 0 || (!pkt && ist->next_pts != ist->pts)) {
+ uint8_t *data_buf, *decoded_data_buf;
+ int data_size, decoded_data_size;
handle_eof:
ist->pts= ist->next_pts;
fprintf(stderr, "Multiple frames in a packet from stream %d\n", pkt->stream_index);
/* decode the packet if needed */
- data_buf = NULL; /* fail safe */
- data_size = 0;
+ decoded_data_buf = NULL; /* fail safe */
+ decoded_data_size= 0;
+ data_buf = avpkt.data;
+ data_size = avpkt.size;
subtitle_to_free = NULL;
if (ist->decoding_needed) {
switch(ist->st->codec->codec_type) {
av_free(samples);
samples= av_malloc(samples_size);
}
- data_size= samples_size;
+ decoded_data_size= samples_size;
/* XXX: could avoid copy if PCM 16 bits with same
endianness as CPU */
- ret = avcodec_decode_audio3(ist->st->codec, samples, &data_size,
+ ret = avcodec_decode_audio3(ist->st->codec, samples, &decoded_data_size,
&avpkt);
if (ret < 0)
goto fail_decode;
avpkt.data += ret;
avpkt.size -= ret;
+ data_size = ret;
/* Some bug in mpeg audio decoder gives */
- /* data_size < 0, it seems they are overflows */
- if (data_size <= 0) {
+ /* decoded_data_size < 0, it seems they are overflows */
+ if (decoded_data_size <= 0) {
/* no audio frame */
continue;
}
- data_buf = (uint8_t *)samples;
- ist->next_pts += ((int64_t)AV_TIME_BASE/bps * data_size) /
+ decoded_data_buf = (uint8_t *)samples;
+ ist->next_pts += ((int64_t)AV_TIME_BASE/bps * decoded_data_size) /
(ist->st->codec->sample_rate * ist->st->codec->channels);
break;}
case CODEC_TYPE_VIDEO:
- data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
+ decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
/* XXX: allocate picture correctly */
avcodec_get_frame_defaults(&picture);
}
break;
}
- data_buf = avpkt.data;
- data_size = avpkt.size;
ret = avpkt.size;
avpkt.size = 0;
}
if (audio_volume != 256) {
short *volp;
volp = samples;
- for(i=0;i<(data_size / sizeof(short));i++) {
+ for(i=0;i<(decoded_data_size / sizeof(short));i++) {
int v = ((*volp) * audio_volume + 128) >> 8;
if (v < -32768) v = -32768;
if (v > 32767) v = 32767;
//ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
if (ost->encoding_needed) {
+ assert(ist->decoding_needed);
switch(ost->st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
- do_audio_out(os, ost, ist, data_buf, data_size);
+ do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
break;
case CODEC_TYPE_VIDEO:
do_video_out(os, ost, ist, &picture, &frame_size);
//FIXME remove the following 2 lines they shall be replaced by the bitstream filters
if(ost->st->codec->codec_id != CODEC_ID_H264) {
- if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
- opkt.destruct= av_destruct_packet;
+ if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
+ opkt.destruct= av_destruct_packet;
} else {
opkt.data = data_buf;
opkt.size = data_size;
AVCodecContext *enc = st->codec;
if(thread_count>1)
avcodec_thread_init(enc, thread_count);
- enc->thread_count= thread_count;
switch(enc->codec_type) {
case CODEC_TYPE_AUDIO:
set_context_opts(enc, avcodec_opts[CODEC_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM);
if(inter_matrix)
video_enc->inter_matrix = inter_matrix;
- video_enc->thread_count = thread_count;
p= video_rc_override_string;
for(i=0; p; i++){
int start, end, q;
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = st->quality = FF_QP2LAMBDA * audio_qscale;
}
- audio_enc->thread_count = thread_count;
audio_enc->channels = audio_channels;
audio_enc->sample_fmt = audio_sample_fmt;
audio_enc->channel_layout = channel_layout;
}
if (last_asked_format) {
- file_oformat = guess_format(last_asked_format, NULL, NULL);
+ file_oformat = av_guess_format(last_asked_format, NULL, NULL);
if (!file_oformat) {
fprintf(stderr, "Requested output format '%s' is not a suitable output format\n", last_asked_format);
av_exit(1);
}
last_asked_format = NULL;
} else {
- file_oformat = guess_format(NULL, filename, NULL);
+ file_oformat = av_guess_format(NULL, filename, NULL);
if (!file_oformat) {
fprintf(stderr, "Unable to find a suitable output format for '%s'\n",
filename);