Commit 921d5ae3 authored by Michael Niedermayer's avatar Michael Niedermayer

ffmpeg: replace remaining, ffmpeg specific ist->st->codec by ist->dec_ctx

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 9fb45334
...@@ -243,7 +243,7 @@ static void sub2video_update(InputStream *ist, AVSubtitle *sub) ...@@ -243,7 +243,7 @@ static void sub2video_update(InputStream *ist, AVSubtitle *sub)
num_rects = 0; num_rects = 0;
} }
if (sub2video_get_blank_frame(ist) < 0) { if (sub2video_get_blank_frame(ist) < 0) {
av_log(ist->st->codec, AV_LOG_ERROR, av_log(ist->dec_ctx, AV_LOG_ERROR,
"Impossible to get a blank canvas.\n"); "Impossible to get a blank canvas.\n");
return; return;
} }
...@@ -1634,11 +1634,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p ...@@ -1634,11 +1634,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
opkt.dts -= ost_tb_start_time; opkt.dts -= ost_tb_start_time;
if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) { if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) {
int duration = av_get_audio_frame_duration(ist->st->codec, pkt->size); int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size);
if(!duration) if(!duration)
duration = ist->st->codec->frame_size; duration = ist->dec_ctx->frame_size;
opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts, opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts,
(AVRational){1, ist->st->codec->sample_rate}, duration, &ist->filter_in_rescale_delta_last, (AVRational){1, ist->dec_ctx->sample_rate}, duration, &ist->filter_in_rescale_delta_last,
ost->st->time_base) - ost_tb_start_time; ost->st->time_base) - ost_tb_start_time;
} }
...@@ -1977,7 +1977,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) ...@@ -1977,7 +1977,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts,
1000, AV_TIME_BASE); 1000, AV_TIME_BASE);
if (end < ist->prev_sub.subtitle.end_display_time) { if (end < ist->prev_sub.subtitle.end_display_time) {
av_log(ist->st->codec, AV_LOG_DEBUG, av_log(ist->dec_ctx, AV_LOG_DEBUG,
"Subtitle duration reduced from %d to %d%s\n", "Subtitle duration reduced from %d to %d%s\n",
ist->prev_sub.subtitle.end_display_time, end, ist->prev_sub.subtitle.end_display_time, end,
end <= 0 ? ", dropping it" : ""); end <= 0 ? ", dropping it" : "");
...@@ -2024,7 +2024,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) ...@@ -2024,7 +2024,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
AVPacket avpkt; AVPacket avpkt;
if (!ist->saw_first_ts) { if (!ist->saw_first_ts) {
ist->dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
ist->pts = 0; ist->pts = 0;
if (pkt != NULL && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { if (pkt != NULL && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
...@@ -2050,7 +2050,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) ...@@ -2050,7 +2050,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
if (pkt->dts != AV_NOPTS_VALUE) { if (pkt->dts != AV_NOPTS_VALUE) {
ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q);
if (ist->st->codec->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed) if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed)
ist->next_pts = ist->pts = ist->dts; ist->next_pts = ist->pts = ist->dts;
} }
...@@ -2108,7 +2108,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) ...@@ -2108,7 +2108,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
// touch data and size only if not EOF // touch data and size only if not EOF
if (pkt) { if (pkt) {
if(ist->st->codec->codec_type != AVMEDIA_TYPE_AUDIO) if(ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO)
ret = avpkt.size; ret = avpkt.size;
avpkt.data += ret; avpkt.data += ret;
avpkt.size -= ret; avpkt.size -= ret;
...@@ -3294,7 +3294,7 @@ static int process_input(int file_index) ...@@ -3294,7 +3294,7 @@ static int process_input(int file_index)
if (debug_ts) { if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s " av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d type:%s "
"next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n", "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type), ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->dec_ctx->codec_type),
av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q), av_ts2str(ist->next_dts), av_ts2timestr(ist->next_dts, &AV_TIME_BASE_Q),
av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q), av_ts2str(ist->next_pts), av_ts2timestr(ist->next_pts, &AV_TIME_BASE_Q),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
...@@ -3372,7 +3372,7 @@ static int process_input(int file_index) ...@@ -3372,7 +3372,7 @@ static int process_input(int file_index)
int64_t delta = pkt_dts - ifile->last_ts; int64_t delta = pkt_dts - ifile->last_ts;
if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE || if(delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE && (delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)){ ist->dec_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)){
ifile->ts_offset -= delta; ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG, av_log(NULL, AV_LOG_DEBUG,
"Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
...@@ -3390,7 +3390,7 @@ static int process_input(int file_index) ...@@ -3390,7 +3390,7 @@ static int process_input(int file_index)
if (is->iformat->flags & AVFMT_TS_DISCONT) { if (is->iformat->flags & AVFMT_TS_DISCONT) {
if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE || if (delta < -1LL*dts_delta_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_delta_threshold*AV_TIME_BASE && (delta > 1LL*dts_delta_threshold*AV_TIME_BASE &&
ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) || ist->dec_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE) ||
pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) { pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) {
ifile->ts_offset -= delta; ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG, av_log(NULL, AV_LOG_DEBUG,
...@@ -3402,7 +3402,7 @@ static int process_input(int file_index) ...@@ -3402,7 +3402,7 @@ static int process_input(int file_index)
} }
} else { } else {
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)) { (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->dec_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)) {
av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index); av_log(NULL, AV_LOG_WARNING, "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", pkt.dts, ist->next_dts, pkt.stream_index);
pkt.dts = AV_NOPTS_VALUE; pkt.dts = AV_NOPTS_VALUE;
} }
...@@ -3410,7 +3410,7 @@ static int process_input(int file_index) ...@@ -3410,7 +3410,7 @@ static int process_input(int file_index)
int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q); int64_t pkt_pts = av_rescale_q(pkt.pts, ist->st->time_base, AV_TIME_BASE_Q);
delta = pkt_pts - ist->next_dts; delta = pkt_pts - ist->next_dts;
if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE || if ( delta < -1LL*dts_error_threshold*AV_TIME_BASE ||
(delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE)) { (delta > 1LL*dts_error_threshold*AV_TIME_BASE && ist->dec_ctx->codec_type != AVMEDIA_TYPE_SUBTITLE)) {
av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index); av_log(NULL, AV_LOG_WARNING, "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", pkt.pts, ist->next_dts, pkt.stream_index);
pkt.pts = AV_NOPTS_VALUE; pkt.pts = AV_NOPTS_VALUE;
} }
...@@ -3423,7 +3423,7 @@ static int process_input(int file_index) ...@@ -3423,7 +3423,7 @@ static int process_input(int file_index)
if (debug_ts) { if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n", av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->st->codec->codec_type), ifile->ist_index + pkt.stream_index, av_get_media_type_string(ist->dec_ctx->codec_type),
av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base), av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ist->st->time_base),
av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base), av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ist->st->time_base),
av_ts2str(input_files[ist->file_index]->ts_offset), av_ts2str(input_files[ist->file_index]->ts_offset),
......
...@@ -595,8 +595,8 @@ static int sub2video_prepare(InputStream *ist) ...@@ -595,8 +595,8 @@ static int sub2video_prepare(InputStream *ist)
/* Compute the size of the canvas for the subtitles stream. /* Compute the size of the canvas for the subtitles stream.
If the subtitles codec has set a size, use it. Otherwise use the If the subtitles codec has set a size, use it. Otherwise use the
maximum dimensions of the video streams in the same file. */ maximum dimensions of the video streams in the same file. */
w = ist->st->codec->width; w = ist->dec_ctx->width;
h = ist->st->codec->height; h = ist->dec_ctx->height;
if (!(w && h)) { if (!(w && h)) {
for (i = 0; i < avf->nb_streams; i++) { for (i = 0; i < avf->nb_streams; i++) {
if (avf->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (avf->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
...@@ -610,12 +610,12 @@ static int sub2video_prepare(InputStream *ist) ...@@ -610,12 +610,12 @@ static int sub2video_prepare(InputStream *ist)
} }
av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h); av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
} }
ist->sub2video.w = ist->st->codec->width = ist->resample_width = w; ist->sub2video.w = ist->dec_ctx->width = ist->resample_width = w;
ist->sub2video.h = ist->st->codec->height = ist->resample_height = h; ist->sub2video.h = ist->dec_ctx->height = ist->resample_height = h;
/* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the /* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
palettes for all rectangles are identical or compatible */ palettes for all rectangles are identical or compatible */
ist->resample_pix_fmt = ist->st->codec->pix_fmt = AV_PIX_FMT_RGB32; ist->resample_pix_fmt = ist->dec_ctx->pix_fmt = AV_PIX_FMT_RGB32;
ist->sub2video.frame = av_frame_alloc(); ist->sub2video.frame = av_frame_alloc();
if (!ist->sub2video.frame) if (!ist->sub2video.frame)
...@@ -638,7 +638,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, ...@@ -638,7 +638,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
char name[255]; char name[255];
int ret, pad_idx = 0; int ret, pad_idx = 0;
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n"); av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
...@@ -646,7 +646,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, ...@@ -646,7 +646,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
if (!fr.num) if (!fr.num)
fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL); fr = av_guess_frame_rate(input_files[ist->file_index]->ctx, ist->st, NULL);
if (ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = sub2video_prepare(ist); ret = sub2video_prepare(ist);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment