fftools/ffmpeg_dec: stop accesing InputStream.fix_sub_duration
Pass this information to dec_open() instead. This is a step towards decoupling Decoder and InputStream.
This commit is contained in:
@@ -280,6 +280,10 @@ typedef struct FilterGraph {
|
|||||||
int nb_outputs;
|
int nb_outputs;
|
||||||
} FilterGraph;
|
} FilterGraph;
|
||||||
|
|
||||||
|
enum DecoderFlags {
|
||||||
|
DECODER_FLAG_FIX_SUB_DURATION = (1 << 0),
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct Decoder {
|
typedef struct Decoder {
|
||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
|
|
||||||
@@ -735,7 +739,7 @@ int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input);
|
|||||||
* is transferred to the decoder.
|
* is transferred to the decoder.
|
||||||
*/
|
*/
|
||||||
int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
||||||
AVDictionary **dec_opts);
|
AVDictionary **dec_opts, int flags);
|
||||||
void dec_free(Decoder **pdec);
|
void dec_free(Decoder **pdec);
|
||||||
|
|
||||||
int dec_add_filter(Decoder *dec, InputFilter *ifilter);
|
int dec_add_filter(Decoder *dec, InputFilter *ifilter);
|
||||||
|
@@ -45,6 +45,9 @@ typedef struct DecoderPriv {
|
|||||||
// override output video sample aspect ratio with this value
|
// override output video sample aspect ratio with this value
|
||||||
AVRational sar_override;
|
AVRational sar_override;
|
||||||
|
|
||||||
|
// a combination of DECODER_FLAG_*, provided to dec_open()
|
||||||
|
int flags;
|
||||||
|
|
||||||
enum AVPixelFormat hwaccel_pix_fmt;
|
enum AVPixelFormat hwaccel_pix_fmt;
|
||||||
|
|
||||||
// pts/estimated duration of the last decoded frame
|
// pts/estimated duration of the last decoded frame
|
||||||
@@ -326,7 +329,7 @@ static int process_subtitle(InputStream *ist, AVFrame *frame)
|
|||||||
const AVSubtitle *subtitle = (AVSubtitle*)frame->buf[0]->data;
|
const AVSubtitle *subtitle = (AVSubtitle*)frame->buf[0]->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ist->fix_sub_duration) {
|
if (dp->flags & DECODER_FLAG_FIX_SUB_DURATION) {
|
||||||
AVSubtitle *sub_prev = dp->sub_prev[0]->buf[0] ?
|
AVSubtitle *sub_prev = dp->sub_prev[0]->buf[0] ?
|
||||||
(AVSubtitle*)dp->sub_prev[0]->buf[0]->data : NULL;
|
(AVSubtitle*)dp->sub_prev[0]->buf[0]->data : NULL;
|
||||||
int end = 1;
|
int end = 1;
|
||||||
@@ -372,7 +375,7 @@ static int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
|
|||||||
(AVSubtitle*)dp->sub_prev[0]->buf[0]->data : NULL;
|
(AVSubtitle*)dp->sub_prev[0]->buf[0]->data : NULL;
|
||||||
AVSubtitle *subtitle;
|
AVSubtitle *subtitle;
|
||||||
|
|
||||||
if (!ist->fix_sub_duration || !prev_subtitle ||
|
if (!(dp->flags & DECODER_FLAG_FIX_SUB_DURATION) || !prev_subtitle ||
|
||||||
!prev_subtitle->num_rects || signal_pts <= prev_subtitle->pts)
|
!prev_subtitle->num_rects || signal_pts <= prev_subtitle->pts)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -895,7 +898,7 @@ static const AVClass dec_class = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
||||||
AVDictionary **dec_opts)
|
AVDictionary **dec_opts, int flags)
|
||||||
{
|
{
|
||||||
DecoderPriv *dp;
|
DecoderPriv *dp;
|
||||||
const AVCodec *codec = ist->dec;
|
const AVCodec *codec = ist->dec;
|
||||||
@@ -909,12 +912,14 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
|||||||
dp->sch = sch;
|
dp->sch = sch;
|
||||||
dp->sch_idx = sch_idx;
|
dp->sch_idx = sch_idx;
|
||||||
|
|
||||||
|
dp->flags = flags;
|
||||||
dp->dec.class = &dec_class;
|
dp->dec.class = &dec_class;
|
||||||
dp->log_parent = ist;
|
dp->log_parent = ist;
|
||||||
|
|
||||||
snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name);
|
snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name);
|
||||||
|
|
||||||
if (codec->type == AVMEDIA_TYPE_SUBTITLE && ist->fix_sub_duration) {
|
if (codec->type == AVMEDIA_TYPE_SUBTITLE &&
|
||||||
|
(dp->flags & DECODER_FLAG_FIX_SUB_DURATION)) {
|
||||||
for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) {
|
for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) {
|
||||||
dp->sub_prev[i] = av_frame_alloc();
|
dp->sub_prev[i] = av_frame_alloc();
|
||||||
if (!dp->sub_prev[i])
|
if (!dp->sub_prev[i])
|
||||||
|
@@ -891,6 +891,7 @@ static int ist_use(InputStream *ist, int decoding_needed)
|
|||||||
|
|
||||||
if (decoding_needed && ds->sch_idx_dec < 0) {
|
if (decoding_needed && ds->sch_idx_dec < 0) {
|
||||||
int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
|
int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
|
||||||
|
int dec_flags = !!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION;
|
||||||
|
|
||||||
ret = sch_add_dec(d->sch, decoder_thread, ist, d->loop && is_audio);
|
ret = sch_add_dec(d->sch, decoder_thread, ist, d->loop && is_audio);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -903,7 +904,7 @@ static int ist_use(InputStream *ist, int decoding_needed)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = dec_open(ist, d->sch, ds->sch_idx_dec,
|
ret = dec_open(ist, d->sch, ds->sch_idx_dec,
|
||||||
&ist->decoder_opts);
|
&ist->decoder_opts, dec_flags);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user