X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=ae02b0078467716338a316a889a9574231c13213;hb=c34c050303b11e3f88fa1be7b43fe9439765e0af;hp=eb3f6134001e8c4e146da121d4f9aab3b04fa04b;hpb=8e67599505e3b0a968227a1dcd40020dff874001;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index eb3f6134001..ae02b007846 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -172,8 +172,8 @@ static int sub2video_get_blank_frame(InputStream *ist) AVFrame *frame = ist->sub2video.frame; av_frame_unref(frame); - ist->sub2video.frame->width = ist->sub2video.w; - ist->sub2video.frame->height = ist->sub2video.h; + ist->sub2video.frame->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w; + ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h; ist->sub2video.frame->format = AV_PIX_FMT_RGB32; if ((ret = av_frame_get_buffer(frame, 32)) < 0) return ret; @@ -193,7 +193,9 @@ static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, return; } if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) { - av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle overflowing\n"); + av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle (%d %d %d %d) overflowing %d %d\n", + r->x, r->y, r->w, r->h, w, h + ); return; } @@ -225,7 +227,6 @@ static void sub2video_push_ref(InputStream *ist, int64_t pts) static void sub2video_update(InputStream *ist, AVSubtitle *sub) { - int w = ist->sub2video.w, h = ist->sub2video.h; AVFrame *frame = ist->sub2video.frame; int8_t *dst; int dst_linesize; @@ -253,7 +254,7 @@ static void sub2video_update(InputStream *ist, AVSubtitle *sub) dst = frame->data [0]; dst_linesize = frame->linesize[0]; for (i = 0; i < num_rects; i++) - sub2video_copy_rect(dst, dst_linesize, w, h, sub->rects[i]); + sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]); sub2video_push_ref(ist, pts); ist->sub2video.end_pts = end_pts; } @@ -294,7 +295,7 @@ static void sub2video_flush(InputStream *ist) if (ist->sub2video.end_pts < INT64_MAX) sub2video_update(ist, NULL); for (i = 0; i < ist->nb_filters; i++) - av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); + av_buffersrc_add_frame(ist->filters[i]->filter, NULL); } /* end of sub2video hack */ @@ -372,7 +373,7 @@ void term_init(void) struct termios tty; int istty = 1; #if HAVE_ISATTY - istty = isatty(0); + istty = isatty(0) && isatty(2); #endif if (istty && tcgetattr (0, &tty) == 0) { oldtty = tty; @@ -434,10 +435,6 @@ static int read_key(void) is_pipe = !GetConsoleMode(input_handle, &dw); } - if (stdin->_cnt > 0) { - read(0, &ch, 1); - return ch; - } if (is_pipe) { /* When running under a GUI, you will end here. */ if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) { @@ -696,7 +693,13 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) &new_pkt.data, &new_pkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY); - if(a == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { +FF_DISABLE_DEPRECATION_WARNINGS + if(a == 0 && new_pkt.data != pkt->data +#if FF_API_DESTRUCT_PACKET + && new_pkt.destruct +#endif + ) { +FF_ENABLE_DEPRECATION_WARNINGS uint8_t *t = av_malloc(new_pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); //the new should be a subset of the old so cannot overflow if(t) { memcpy(t, new_pkt.data, new_pkt.size); @@ -1154,7 +1157,7 @@ static void do_video_out(AVFormatContext *s, ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; res = av_expr_eval(ost->forced_keyframes_pexpr, ost->forced_keyframes_expr_const_values, NULL); - av_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", + ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", ost->forced_keyframes_expr_const_values[FKF_N], ost->forced_keyframes_expr_const_values[FKF_N_FORCED], ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], @@ -1746,7 +1749,9 @@ static void flush_encoders(void) ret = encode(enc, &pkt, NULL, &got_packet); update_benchmark("flush %s %d.%d", desc, ost->file_index, ost->index); if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, "%s encoding failed\n", desc); + av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", + desc, + av_err2str(ret)); exit_program(1); } if (ost->logfile && enc->stats_out) { @@ -1862,17 +1867,22 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base); opkt.flags = pkt->flags; - // FIXME remove the following 2 lines they shall be replaced by the bitstream filters - if ( ost->enc_ctx->codec_id != AV_CODEC_ID_H264 - && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG1VIDEO - && ost->enc_ctx->codec_id != AV_CODEC_ID_MPEG2VIDEO - && ost->enc_ctx->codec_id != AV_CODEC_ID_VC1 + if ( ost->st->codec->codec_id != AV_CODEC_ID_H264 + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_VC1 ) { - if (av_parser_change(ost->parser, ost->st->codec, + int ret = av_parser_change(ost->parser, ost->st->codec, &opkt.data, &opkt.size, pkt->data, pkt->size, - pkt->flags & AV_PKT_FLAG_KEY)) { + pkt->flags & AV_PKT_FLAG_KEY); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "av_parser_change failed: %s\n", + av_err2str(ret)); + exit_program(1); + } + if (ret) { opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0); if (!opkt.buf) exit_program(1); @@ -1883,9 +1893,16 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } av_copy_packet_side_data(&opkt, pkt); - if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) { + if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && + ost->st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && + (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) { /* store AVPicture in AVPacket, as expected by the output format */ - avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height); + int ret = avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "avpicture_fill failed: %s\n", + av_err2str(ret)); + exit_program(1); + } opkt.data = (uint8_t *)&pict; opkt.size = sizeof(AVPicture); opkt.flags |= AV_PKT_FLAG_KEY; @@ -2067,12 +2084,13 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) { ist->st->codec->has_b_frames = ist->dec_ctx->has_b_frames; } else - av_log_ask_for_sample( - ist->dec_ctx, - "has_b_frames is larger in decoder than demuxer %d > %d ", - ist->dec_ctx->has_b_frames, - ist->st->codec->has_b_frames - ); + av_log(ist->dec_ctx, AV_LOG_WARNING, + "has_b_frames is larger in decoder than demuxer %d > %d.\n" + "If you want to help, upload a sample " + "of this file to ftp://upload.ffmpeg.org/incoming/ " + "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)", + ist->dec_ctx->has_b_frames, + ist->st->codec->has_b_frames); } if (*got_output || ret<0) @@ -2248,11 +2266,7 @@ static int send_filter_eof(InputStream *ist) { int i, ret; for (i = 0; i < ist->nb_filters; i++) { -#if 1 - ret = av_buffersrc_add_ref(ist->filters[i]->filter, NULL, 0); -#else ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); -#endif if (ret < 0) return ret; } @@ -3428,9 +3442,17 @@ static int check_keyboard_interaction(int64_t cur_time) if(!debug) debug = 1; while(debug & (FF_DEBUG_DCT_COEFF|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) //unsupported, would just crash debug += debug; - }else - if(scanf("%d", &debug)!=1) + }else{ + char buf[32]; + int k = 0; + i = 0; + while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1) + if (k > 0) + buf[i++] = k; + buf[i] = 0; + if (k <= 0 || sscanf(buf, "%d", &debug)!=1) fprintf(stderr,"error parsing debug value\n"); + } for(i=0;ist->codec->debug = debug; } @@ -4030,6 +4052,7 @@ static int transcode(void) av_freep(&ost->apad); av_freep(&ost->disposition); av_dict_free(&ost->encoder_opts); + av_dict_free(&ost->sws_dict); av_dict_free(&ost->swr_opts); av_dict_free(&ost->resample_opts); av_dict_free(&ost->bsf_args);