提交 a686caf0 编写于 作者: R Roman Shaposhnik

* fixing bug that prevented resampling the picture and

     changing pix_fmt at the same time.

   * aspect ratio should be more reliable for DV now.

Originally committed as revision 2338 to svn://svn.ffmpeg.org/ffmpeg/trunk
上级 e692fd60
...@@ -467,6 +467,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -467,6 +467,7 @@ static void do_video_out(AVFormatContext *s,
static uint8_t *video_buffer; static uint8_t *video_buffer;
uint8_t *buf = NULL, *buf1 = NULL; uint8_t *buf = NULL, *buf1 = NULL;
AVCodecContext *enc, *dec; AVCodecContext *enc, *dec;
enum PixelFormat target_pixfmt;
#define VIDEO_BUFFER_SIZE (1024*1024) #define VIDEO_BUFFER_SIZE (1024*1024)
...@@ -534,7 +535,8 @@ static void do_video_out(AVFormatContext *s, ...@@ -534,7 +535,8 @@ static void do_video_out(AVFormatContext *s,
return; return;
/* convert pixel format if needed */ /* convert pixel format if needed */
if (enc->pix_fmt != dec->pix_fmt) { target_pixfmt = ost->video_resample ? PIX_FMT_YUV420P : enc->pix_fmt;
if (dec->pix_fmt != target_pixfmt) {
int size; int size;
/* create temporary picture */ /* create temporary picture */
...@@ -545,7 +547,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -545,7 +547,7 @@ static void do_video_out(AVFormatContext *s,
formatted_picture = &picture_format_temp; formatted_picture = &picture_format_temp;
avpicture_fill(formatted_picture, buf, enc->pix_fmt, dec->width, dec->height); avpicture_fill(formatted_picture, buf, enc->pix_fmt, dec->width, dec->height);
if (img_convert(formatted_picture, enc->pix_fmt, if (img_convert(formatted_picture, target_pixfmt,
in_picture, dec->pix_fmt, in_picture, dec->pix_fmt,
dec->width, dec->height) < 0) { dec->width, dec->height) < 0) {
fprintf(stderr, "pixel format conversion not handled\n"); fprintf(stderr, "pixel format conversion not handled\n");
...@@ -561,6 +563,25 @@ static void do_video_out(AVFormatContext *s, ...@@ -561,6 +563,25 @@ static void do_video_out(AVFormatContext *s,
if (ost->video_resample) { if (ost->video_resample) {
final_picture = &ost->pict_tmp; final_picture = &ost->pict_tmp;
img_resample(ost->img_resample_ctx, final_picture, formatted_picture); img_resample(ost->img_resample_ctx, final_picture, formatted_picture);
if (enc->pix_fmt != PIX_FMT_YUV420P) {
int size;
av_free(buf);
/* create temporary picture */
size = avpicture_get_size(enc->pix_fmt, enc->width, enc->height);
buf = av_malloc(size);
if (!buf)
return;
final_picture = &picture_format_temp;
avpicture_fill(final_picture, buf, enc->pix_fmt, enc->width, enc->height);
if (img_convert(final_picture, enc->pix_fmt,
&ost->pict_tmp, PIX_FMT_YUV420P,
enc->width, enc->height) < 0) {
fprintf(stderr, "pixel format conversion not handled\n");
goto the_end;
}
}
} else if (ost->video_crop) { } else if (ost->video_crop) {
picture_crop_temp.data[0] = formatted_picture->data[0] + picture_crop_temp.data[0] = formatted_picture->data[0] +
(ost->topBand * formatted_picture->linesize[0]) + ost->leftBand; (ost->topBand * formatted_picture->linesize[0]) + ost->leftBand;
......
...@@ -660,7 +660,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) ...@@ -660,7 +660,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
c->has_audio = c->has_video = 0; c->has_audio = c->has_video = 0;
c->start_time = time(NULL); c->start_time = time(NULL);
c->aspect = 0; /* 4:3 is the default */ c->aspect = 0; /* 4:3 is the default */
if (vst->codec.aspect_ratio == 16.0 / 9.0) if ((int)(vst->codec.aspect_ratio * 10) == 17) /* 16:9 */
c->aspect = 0x07; c->aspect = 0x07;
if (fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) if (fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册