summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-12-04 10:04:03 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-12-04 10:04:03 +0000
commit1e491e29c27cf6a6925666e4f4eac41b65e263d7 (patch)
tree99879470b8deeb55e7d88c62729b62ac27d249ee /ffmpeg.c
parent855ea723b0ea450137e54674179751c14e8fc6b5 (diff)
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
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 2e76f384ea..109bbf95ad 100644
--- a/ffmpeg.c
+++ b/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;