fixed top_field_first support when encoding
Originally committed as revision 2600 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
3e9d718ecb
commit
7a0f9d7e7d
60
ffmpeg.c
60
ffmpeg.c
@ -465,7 +465,7 @@ static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void
|
|||||||
static void do_video_out(AVFormatContext *s,
|
static void do_video_out(AVFormatContext *s,
|
||||||
AVOutputStream *ost,
|
AVOutputStream *ost,
|
||||||
AVInputStream *ist,
|
AVInputStream *ist,
|
||||||
AVPicture *in_picture,
|
AVFrame *in_picture,
|
||||||
int *frame_size, AVOutputStream *audio_sync)
|
int *frame_size, AVOutputStream *audio_sync)
|
||||||
{
|
{
|
||||||
int nb_frames, i, ret;
|
int nb_frames, i, ret;
|
||||||
@ -557,13 +557,13 @@ static void do_video_out(AVFormatContext *s,
|
|||||||
avpicture_fill(formatted_picture, buf, target_pixfmt, dec->width, dec->height);
|
avpicture_fill(formatted_picture, buf, target_pixfmt, dec->width, dec->height);
|
||||||
|
|
||||||
if (img_convert(formatted_picture, target_pixfmt,
|
if (img_convert(formatted_picture, target_pixfmt,
|
||||||
in_picture, dec->pix_fmt,
|
(AVPicture *)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");
|
||||||
goto the_end;
|
goto the_end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formatted_picture = in_picture;
|
formatted_picture = (AVPicture *)in_picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: resampling could be done before raw format convertion in
|
/* XXX: resampling could be done before raw format convertion in
|
||||||
@ -627,6 +627,10 @@ static void do_video_out(AVFormatContext *s,
|
|||||||
|
|
||||||
memset(&big_picture, 0, sizeof(AVFrame));
|
memset(&big_picture, 0, sizeof(AVFrame));
|
||||||
*(AVPicture*)&big_picture= *final_picture;
|
*(AVPicture*)&big_picture= *final_picture;
|
||||||
|
/* better than nothing: use input picture interlaced
|
||||||
|
settings */
|
||||||
|
big_picture.interlaced_frame = in_picture->interlaced_frame;
|
||||||
|
big_picture.top_field_first = in_picture->top_field_first;
|
||||||
|
|
||||||
/* handles sameq here. This is not correct because it may
|
/* handles sameq here. This is not correct because it may
|
||||||
not be a global option */
|
not be a global option */
|
||||||
@ -1187,7 +1191,7 @@ static int av_encode(AVFormatContext **output_files,
|
|||||||
int len;
|
int len;
|
||||||
uint8_t *data_buf;
|
uint8_t *data_buf;
|
||||||
int data_size, got_picture;
|
int data_size, got_picture;
|
||||||
AVPicture picture;
|
AVFrame picture;
|
||||||
short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
|
short samples[AVCODEC_MAX_AUDIO_FRAME_SIZE / 2];
|
||||||
void *buffer_to_free;
|
void *buffer_to_free;
|
||||||
double pts_min;
|
double pts_min;
|
||||||
@ -1285,32 +1289,27 @@ static int av_encode(AVFormatContext **output_files,
|
|||||||
(2 * ist->st->codec.channels);
|
(2 * ist->st->codec.channels);
|
||||||
break;
|
break;
|
||||||
case CODEC_TYPE_VIDEO:
|
case CODEC_TYPE_VIDEO:
|
||||||
{
|
data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2;
|
||||||
AVFrame big_picture;
|
ret = avcodec_decode_video(&ist->st->codec,
|
||||||
|
&picture, &got_picture, ptr, len);
|
||||||
data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2;
|
ist->st->quality= picture.quality;
|
||||||
ret = avcodec_decode_video(&ist->st->codec,
|
if (ret < 0) {
|
||||||
&big_picture, &got_picture, ptr, len);
|
fail_decode:
|
||||||
picture= *(AVPicture*)&big_picture;
|
fprintf(stderr, "Error while decoding stream #%d.%d\n",
|
||||||
ist->st->quality= big_picture.quality;
|
ist->file_index, ist->index);
|
||||||
if (ret < 0) {
|
av_free_packet(&pkt);
|
||||||
fail_decode:
|
goto redo;
|
||||||
fprintf(stderr, "Error while decoding stream #%d.%d\n",
|
|
||||||
ist->file_index, ist->index);
|
|
||||||
av_free_packet(&pkt);
|
|
||||||
goto redo;
|
|
||||||
}
|
|
||||||
if (!got_picture) {
|
|
||||||
/* no picture yet */
|
|
||||||
goto discard_packet;
|
|
||||||
}
|
|
||||||
if (ist->st->codec.frame_rate_base != 0) {
|
|
||||||
ist->next_pts += ((int64_t)AV_TIME_BASE *
|
|
||||||
ist->st->codec.frame_rate_base) /
|
|
||||||
ist->st->codec.frame_rate;
|
|
||||||
}
|
|
||||||
len = 0;
|
|
||||||
}
|
}
|
||||||
|
if (!got_picture) {
|
||||||
|
/* no picture yet */
|
||||||
|
goto discard_packet;
|
||||||
|
}
|
||||||
|
if (ist->st->codec.frame_rate_base != 0) {
|
||||||
|
ist->next_pts += ((int64_t)AV_TIME_BASE *
|
||||||
|
ist->st->codec.frame_rate_base) /
|
||||||
|
ist->st->codec.frame_rate;
|
||||||
|
}
|
||||||
|
len = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto fail_decode;
|
goto fail_decode;
|
||||||
@ -1324,7 +1323,8 @@ static int av_encode(AVFormatContext **output_files,
|
|||||||
|
|
||||||
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, &picture, &buffer_to_free);
|
pre_process_video_frame(ist, (AVPicture *)&picture,
|
||||||
|
&buffer_to_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* frame rate emulation */
|
/* frame rate emulation */
|
||||||
|
@ -448,7 +448,11 @@ void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number)
|
|||||||
}
|
}
|
||||||
put_bits(&s->pb, 2, s->intra_dc_precision);
|
put_bits(&s->pb, 2, s->intra_dc_precision);
|
||||||
put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME);
|
put_bits(&s->pb, 2, s->picture_structure= PICT_FRAME);
|
||||||
put_bits(&s->pb, 1, s->top_field_first);
|
if (s->progressive_sequence) {
|
||||||
|
put_bits(&s->pb, 1, 0); /* no repeat */
|
||||||
|
} else {
|
||||||
|
put_bits(&s->pb, 1, s->current_picture_ptr->top_field_first);
|
||||||
|
}
|
||||||
/* XXX: optimize the generation of this flag with entropy
|
/* XXX: optimize the generation of this flag with entropy
|
||||||
measures */
|
measures */
|
||||||
s->frame_pred_frame_dct = s->progressive_sequence;
|
s->frame_pred_frame_dct = s->progressive_sequence;
|
||||||
|
@ -1560,6 +1560,8 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
|
|||||||
pic->quality= pic_arg->quality;
|
pic->quality= pic_arg->quality;
|
||||||
pic->pict_type= pic_arg->pict_type;
|
pic->pict_type= pic_arg->pict_type;
|
||||||
pic->pts = pic_arg->pts;
|
pic->pts = pic_arg->pts;
|
||||||
|
pic->interlaced_frame = pic_arg->interlaced_frame;
|
||||||
|
pic->top_field_first = pic_arg->top_field_first;
|
||||||
|
|
||||||
if(s->input_picture[encoding_delay])
|
if(s->input_picture[encoding_delay])
|
||||||
pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1;
|
pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user