提交 bde0705c 编写于 作者: L Limin Wang 提交者: Diego Biurrun

cosmetics: Fix indentation, patch by Limin Wang, lance.lmwang gmail com.

Originally committed as revision 8340 to svn://svn.ffmpeg.org/ffmpeg/trunk
上级 750f0e1f
...@@ -1100,165 +1100,165 @@ static int output_packet(AVInputStream *ist, int ist_index, ...@@ -1100,165 +1100,165 @@ static int output_packet(AVInputStream *ist, int ist_index,
goto fail_decode; goto fail_decode;
} }
} else { } else {
switch(ist->st->codec->codec_type) { switch(ist->st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) / ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
(ist->st->codec->sample_rate * ist->st->codec->channels); (ist->st->codec->sample_rate * ist->st->codec->channels);
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
if (ist->st->codec->time_base.num != 0) { if (ist->st->codec->time_base.num != 0) {
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec->time_base.num) / ist->st->codec->time_base.num) /
ist->st->codec->time_base.den; ist->st->codec->time_base.den;
}
break;
} }
data_buf = ptr; break;
data_size = len;
ret = len;
len = 0;
}
buffer_to_free = NULL;
if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
pre_process_video_frame(ist, (AVPicture *)&picture,
&buffer_to_free);
} }
data_buf = ptr;
// preprocess audio (volume) data_size = len;
if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) { ret = len;
if (audio_volume != 256) { len = 0;
short *volp; }
volp = samples;
for(i=0;i<(data_size / sizeof(short));i++) { buffer_to_free = NULL;
int v = ((*volp) * audio_volume + 128) >> 8; if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
if (v < -32768) v = -32768; pre_process_video_frame(ist, (AVPicture *)&picture,
if (v > 32767) v = 32767; &buffer_to_free);
*volp++ = v; }
}
// preprocess audio (volume)
if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
if (audio_volume != 256) {
short *volp;
volp = samples;
for(i=0;i<(data_size / sizeof(short));i++) {
int v = ((*volp) * audio_volume + 128) >> 8;
if (v < -32768) v = -32768;
if (v > 32767) v = 32767;
*volp++ = v;
} }
} }
}
/* frame rate emulation */ /* frame rate emulation */
if (ist->st->codec->rate_emu) { if (ist->st->codec->rate_emu) {
int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den); int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
int64_t now = av_gettime() - ist->start; int64_t now = av_gettime() - ist->start;
if (pts > now) if (pts > now)
usleep(pts - now); usleep(pts - now);
ist->frame++; ist->frame++;
} }
#if 0 #if 0
/* mpeg PTS deordering : if it is a P or I frame, the PTS /* mpeg PTS deordering : if it is a P or I frame, the PTS
is the one of the next displayed one */ is the one of the next displayed one */
/* XXX: add mpeg4 too ? */ /* XXX: add mpeg4 too ? */
if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) { if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
if (ist->st->codec->pict_type != B_TYPE) { if (ist->st->codec->pict_type != B_TYPE) {
int64_t tmp; int64_t tmp;
tmp = ist->last_ip_pts; tmp = ist->last_ip_pts;
ist->last_ip_pts = ist->frac_pts.val; ist->last_ip_pts = ist->frac_pts.val;
ist->frac_pts.val = tmp; ist->frac_pts.val = tmp;
}
} }
}
#endif #endif
/* if output time reached then transcode raw format, /* if output time reached then transcode raw format,
encode packets and output them */ encode packets and output them */
if (start_time == 0 || ist->pts >= start_time) if (start_time == 0 || ist->pts >= start_time)
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
int frame_size; int frame_size;
ost = ost_table[i]; ost = ost_table[i];
if (ost->source_index == ist_index) { if (ost->source_index == ist_index) {
os = output_files[ost->file_index]; os = output_files[ost->file_index];
#if 0 #if 0
printf("%d: got pts=%0.3f %0.3f\n", i, printf("%d: got pts=%0.3f %0.3f\n", i,
(double)pkt->pts / AV_TIME_BASE, (double)pkt->pts / AV_TIME_BASE,
((double)ist->pts / AV_TIME_BASE) - ((double)ist->pts / AV_TIME_BASE) -
((double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den)); ((double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den));
#endif #endif
/* set the input output pts pairs */ /* set the input output pts pairs */
//ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE; //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
if (ost->encoding_needed) {
switch(ost->st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
do_audio_out(os, ost, ist, data_buf, data_size);
break;
case CODEC_TYPE_VIDEO:
do_video_out(os, ost, ist, &picture, &frame_size);
video_size += frame_size;
if (do_vstats && frame_size)
do_video_stats(os, ost, frame_size);
break;
case CODEC_TYPE_SUBTITLE:
do_subtitle_out(os, ost, ist, &subtitle,
pkt->pts);
break;
default:
av_abort();
}
} else {
AVFrame avframe; //FIXME/XXX remove this
AVPacket opkt;
av_init_packet(&opkt);
/* no reencoding needed : output the packet directly */
/* force the input stream PTS */
avcodec_get_frame_defaults(&avframe);
ost->st->codec->coded_frame= &avframe;
avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO)
audio_size += data_size;
else if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
video_size += data_size;
ost->sync_opts++;
}
opkt.stream_index= ost->index; if (ost->encoding_needed) {
if(pkt->pts != AV_NOPTS_VALUE) switch(ost->st->codec->codec_type) {
opkt.pts= av_rescale_q(av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q) + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base); case CODEC_TYPE_AUDIO:
else do_audio_out(os, ost, ist, data_buf, data_size);
opkt.pts= AV_NOPTS_VALUE; break;
case CODEC_TYPE_VIDEO:
{ do_video_out(os, ost, ist, &picture, &frame_size);
int64_t dts; video_size += frame_size;
if (pkt->dts == AV_NOPTS_VALUE) if (do_vstats && frame_size)
dts = ist->next_pts; do_video_stats(os, ost, frame_size);
else break;
dts= av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); case CODEC_TYPE_SUBTITLE:
opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base); do_subtitle_out(os, ost, ist, &subtitle,
} pkt->pts);
opkt.flags= pkt->flags; break;
default:
av_abort();
}
} else {
AVFrame avframe; //FIXME/XXX remove this
AVPacket opkt;
av_init_packet(&opkt);
/* no reencoding needed : output the packet directly */
/* force the input stream PTS */
avcodec_get_frame_defaults(&avframe);
ost->st->codec->coded_frame= &avframe;
avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO)
audio_size += data_size;
else if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
video_size += data_size;
ost->sync_opts++;
}
//FIXME remove the following 2 lines they shall be replaced by the bitstream filters opkt.stream_index= ost->index;
if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY)) if(pkt->pts != AV_NOPTS_VALUE)
opkt.destruct= av_destruct_packet; opkt.pts= av_rescale_q(av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q) + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
else
opkt.pts= AV_NOPTS_VALUE;
write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][pkt->stream_index]); {
ost->st->codec->frame_number++; int64_t dts;
ost->frame_number++; if (pkt->dts == AV_NOPTS_VALUE)
av_free_packet(&opkt); dts = ist->next_pts;
else
dts= av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
} }
opkt.flags= pkt->flags;
//FIXME remove the following 2 lines they shall be replaced by the bitstream filters
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;
write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][pkt->stream_index]);
ost->st->codec->frame_number++;
ost->frame_number++;
av_free_packet(&opkt);
} }
} }
av_free(buffer_to_free); }
/* XXX: allocate the subtitles in the codec ? */ av_free(buffer_to_free);
if (subtitle_to_free) { /* XXX: allocate the subtitles in the codec ? */
if (subtitle_to_free->rects != NULL) { if (subtitle_to_free) {
for (i = 0; i < subtitle_to_free->num_rects; i++) { if (subtitle_to_free->rects != NULL) {
av_free(subtitle_to_free->rects[i].bitmap); for (i = 0; i < subtitle_to_free->num_rects; i++) {
av_free(subtitle_to_free->rects[i].rgba_palette); av_free(subtitle_to_free->rects[i].bitmap);
} av_free(subtitle_to_free->rects[i].rgba_palette);
av_freep(&subtitle_to_free->rects);
} }
subtitle_to_free->num_rects = 0; av_freep(&subtitle_to_free->rects);
subtitle_to_free = NULL;
} }
subtitle_to_free->num_rects = 0;
subtitle_to_free = NULL;
} }
}
discard_packet: discard_packet:
if (pkt == NULL) { if (pkt == NULL) {
/* EOF handling */ /* EOF handling */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册