You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
cleanup
adding AVVideoFrame moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame removing obsolete variables in AVCodecContext skiping of MBs in b frames correctly initalizing AVCodecContext picture buffer cleanup Originally committed as revision 1302 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
35
ffmpeg.c
35
ffmpeg.c
@@ -285,6 +285,7 @@ int read_ffserver_streams(AVFormatContext *s, const char *filename)
|
||||
s->nb_streams = ic->nb_streams;
|
||||
for(i=0;i<ic->nb_streams;i++) {
|
||||
AVStream *st;
|
||||
|
||||
st = av_mallocz(sizeof(AVFormatContext));
|
||||
memcpy(st, ic->streams[i], sizeof(AVStream));
|
||||
s->streams[i] = st;
|
||||
@@ -605,15 +606,21 @@ static void do_video_out(AVFormatContext *s,
|
||||
/* XXX: pb because no interleaving */
|
||||
for(i=0;i<nb_frames;i++) {
|
||||
if (enc->codec_id != CODEC_ID_RAWVIDEO) {
|
||||
AVVideoFrame big_picture;
|
||||
|
||||
memset(&big_picture, 0, sizeof(AVVideoFrame));
|
||||
*(AVPicture*)&big_picture= *picture;
|
||||
|
||||
/* handles sameq here. This is not correct because it may
|
||||
not be a global option */
|
||||
if (same_quality) {
|
||||
enc->quality = dec->quality;
|
||||
}
|
||||
big_picture.quality = ist->st->quality;
|
||||
}else
|
||||
big_picture.quality = ost->st->quality;
|
||||
|
||||
ret = avcodec_encode_video(enc,
|
||||
video_buffer, VIDEO_BUFFER_SIZE,
|
||||
picture);
|
||||
&big_picture);
|
||||
//enc->frame_number = enc->real_pict_num;
|
||||
av_write_frame(s, ost->index, video_buffer, ret);
|
||||
*frame_size = ret;
|
||||
@@ -674,7 +681,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
|
||||
total_size += frame_size;
|
||||
if (enc->codec_type == CODEC_TYPE_VIDEO) {
|
||||
frame_number = ost->frame_number;
|
||||
fprintf(fvstats, "frame= %5d q= %2d ", frame_number, enc->quality);
|
||||
fprintf(fvstats, "frame= %5d q= %2.1f ", frame_number, enc->coded_picture->quality);
|
||||
if (do_psnr)
|
||||
fprintf(fvstats, "PSNR= %6.2f ", enc->psnr_y);
|
||||
|
||||
@@ -688,7 +695,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
|
||||
avg_bitrate = (double)(total_size * 8) / ti1 / 1000.0;
|
||||
fprintf(fvstats, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
|
||||
(double)total_size / 1024, ti1, bitrate, avg_bitrate);
|
||||
fprintf(fvstats,"type= %s\n", enc->key_frame == 1 ? "I" : "P");
|
||||
fprintf(fvstats,"type= %s\n", enc->coded_picture->key_frame == 1 ? "I" : "P");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,13 +738,13 @@ void print_report(AVFormatContext **output_files,
|
||||
os = output_files[ost->file_index];
|
||||
enc = &ost->st->codec;
|
||||
if (vid && enc->codec_type == CODEC_TYPE_VIDEO) {
|
||||
sprintf(buf + strlen(buf), "q=%2d ",
|
||||
enc->quality);
|
||||
sprintf(buf + strlen(buf), "q=%2.1f ",
|
||||
enc->coded_picture->quality);
|
||||
}
|
||||
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
|
||||
frame_number = ost->frame_number;
|
||||
sprintf(buf + strlen(buf), "frame=%5d q=%2d ",
|
||||
frame_number, enc->quality);
|
||||
sprintf(buf + strlen(buf), "frame=%5d q=%2.1f ",
|
||||
frame_number, enc->coded_picture ? enc->coded_picture->quality : 0);
|
||||
if (do_psnr)
|
||||
sprintf(buf + strlen(buf), "PSNR=%6.2f ", enc->psnr_y);
|
||||
vid = 1;
|
||||
@@ -1236,9 +1243,13 @@ static int av_encode(AVFormatContext **output_files,
|
||||
ist->st->codec.height);
|
||||
ret = len;
|
||||
} else {
|
||||
AVVideoFrame big_picture;
|
||||
|
||||
data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2;
|
||||
ret = avcodec_decode_video(&ist->st->codec,
|
||||
&picture, &got_picture, ptr, len);
|
||||
&big_picture, &got_picture, ptr, len);
|
||||
picture= *(AVPicture*)&big_picture;
|
||||
ist->st->quality= big_picture.quality;
|
||||
if (ret < 0) {
|
||||
fail_decode:
|
||||
fprintf(stderr, "Error while decoding stream #%d.%d\n",
|
||||
@@ -2046,6 +2057,7 @@ void opt_output_file(const char *filename)
|
||||
fprintf(stderr, "Could not alloc stream\n");
|
||||
exit(1);
|
||||
}
|
||||
avcodec_get_context_defaults(&st->codec);
|
||||
|
||||
video_enc = &st->codec;
|
||||
if (video_stream_copy) {
|
||||
@@ -2074,7 +2086,7 @@ void opt_output_file(const char *filename)
|
||||
video_enc->gop_size = 0;
|
||||
if (video_qscale || same_quality) {
|
||||
video_enc->flags |= CODEC_FLAG_QSCALE;
|
||||
video_enc->quality = video_qscale;
|
||||
st->quality = video_qscale;
|
||||
}
|
||||
|
||||
if (use_hq) {
|
||||
@@ -2181,6 +2193,7 @@ void opt_output_file(const char *filename)
|
||||
fprintf(stderr, "Could not alloc stream\n");
|
||||
exit(1);
|
||||
}
|
||||
avcodec_get_context_defaults(&st->codec);
|
||||
|
||||
audio_enc = &st->codec;
|
||||
audio_enc->codec_type = CODEC_TYPE_AUDIO;
|
||||
|
||||
Reference in New Issue
Block a user