1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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

Originally committed as revision 8340 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Limin Wang 2007-03-12 14:35:36 +00:00 committed by Diego Biurrun
parent 750f0e1f8b
commit bde0705c8c

304
ffmpeg.c
View File

@ -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;
} }
data_buf = ptr;
data_size = len;
ret = len;
len = 0;
}
buffer_to_free = NULL; buffer_to_free = NULL;
if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) { if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
pre_process_video_frame(ist, (AVPicture *)&picture, pre_process_video_frame(ist, (AVPicture *)&picture,
&buffer_to_free); &buffer_to_free);
} }
// preprocess audio (volume) // preprocess audio (volume)
if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) { if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
if (audio_volume != 256) { if (audio_volume != 256) {
short *volp; short *volp;
volp = samples; volp = samples;
for(i=0;i<(data_size / sizeof(short));i++) { for(i=0;i<(data_size / sizeof(short));i++) {
int v = ((*volp) * audio_volume + 128) >> 8; int v = ((*volp) * audio_volume + 128) >> 8;
if (v < -32768) v = -32768; if (v < -32768) v = -32768;
if (v > 32767) v = 32767; if (v > 32767) v = 32767;
*volp++ = v; *volp++ = v;
}
} }
} }
/* frame rate emulation */
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 now = av_gettime() - ist->start;
if (pts > now)
usleep(pts - now);
ist->frame++;
}
#if 0
/* mpeg PTS deordering : if it is a P or I frame, the PTS
is the one of the next displayed one */
/* XXX: add mpeg4 too ? */
if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
if (ist->st->codec->pict_type != B_TYPE) {
int64_t tmp;
tmp = ist->last_ip_pts;
ist->last_ip_pts = ist->frac_pts.val;
ist->frac_pts.val = tmp;
}
}
#endif
/* if output time reached then transcode raw format,
encode packets and output them */
if (start_time == 0 || ist->pts >= start_time)
for(i=0;i<nb_ostreams;i++) {
int frame_size;
ost = ost_table[i];
if (ost->source_index == ist_index) {
os = output_files[ost->file_index];
#if 0
printf("%d: got pts=%0.3f %0.3f\n", i,
(double)pkt->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));
#endif
/* set the input output pts pairs */
//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(pkt->pts != AV_NOPTS_VALUE)
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;
{
int64_t dts;
if (pkt->dts == AV_NOPTS_VALUE)
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 ? */
if (subtitle_to_free) {
if (subtitle_to_free->rects != NULL) {
for (i = 0; i < subtitle_to_free->num_rects; i++) {
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;
subtitle_to_free = NULL;
}
} }
/* frame rate emulation */
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 now = av_gettime() - ist->start;
if (pts > now)
usleep(pts - now);
ist->frame++;
}
#if 0
/* mpeg PTS deordering : if it is a P or I frame, the PTS
is the one of the next displayed one */
/* XXX: add mpeg4 too ? */
if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
if (ist->st->codec->pict_type != B_TYPE) {
int64_t tmp;
tmp = ist->last_ip_pts;
ist->last_ip_pts = ist->frac_pts.val;
ist->frac_pts.val = tmp;
}
}
#endif
/* if output time reached then transcode raw format,
encode packets and output them */
if (start_time == 0 || ist->pts >= start_time)
for(i=0;i<nb_ostreams;i++) {
int frame_size;
ost = ost_table[i];
if (ost->source_index == ist_index) {
os = output_files[ost->file_index];
#if 0
printf("%d: got pts=%0.3f %0.3f\n", i,
(double)pkt->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));
#endif
/* set the input output pts pairs */
//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(pkt->pts != AV_NOPTS_VALUE)
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;
{
int64_t dts;
if (pkt->dts == AV_NOPTS_VALUE)
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 ? */
if (subtitle_to_free) {
if (subtitle_to_free->rects != NULL) {
for (i = 0; i < subtitle_to_free->num_rects; i++) {
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;
subtitle_to_free = NULL;
}
}
discard_packet: discard_packet:
if (pkt == NULL) { if (pkt == NULL) {
/* EOF handling */ /* EOF handling */