fftools/ffmpeg_dec: export subtitle_header in Decoder
This way the encoder does not need to access the decoder AVCodecContext, which will allow to make it private in future commits.
This commit is contained in:
parent
3b84140a1b
commit
b43d4a0692
@ -281,7 +281,8 @@ typedef struct FilterGraph {
|
|||||||
} FilterGraph;
|
} FilterGraph;
|
||||||
|
|
||||||
typedef struct Decoder {
|
typedef struct Decoder {
|
||||||
char dummy;
|
const uint8_t *subtitle_header;
|
||||||
|
int subtitle_header_size;
|
||||||
} Decoder;
|
} Decoder;
|
||||||
|
|
||||||
typedef struct InputStream {
|
typedef struct InputStream {
|
||||||
|
@ -969,5 +969,8 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
dp->dec.subtitle_header = ist->dec_ctx->subtitle_header;
|
||||||
|
dp->dec.subtitle_header_size = ist->dec_ctx->subtitle_header_size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ int enc_open(void *opaque, const AVFrame *frame)
|
|||||||
InputStream *ist = ost->ist;
|
InputStream *ist = ost->ist;
|
||||||
Encoder *e = ost->enc;
|
Encoder *e = ost->enc;
|
||||||
AVCodecContext *enc_ctx = ost->enc_ctx;
|
AVCodecContext *enc_ctx = ost->enc_ctx;
|
||||||
AVCodecContext *dec_ctx = NULL;
|
Decoder *dec;
|
||||||
const AVCodec *enc = enc_ctx->codec;
|
const AVCodec *enc = enc_ctx->codec;
|
||||||
OutputFile *of = ost->file;
|
OutputFile *of = ost->file;
|
||||||
FrameData *fd;
|
FrameData *fd;
|
||||||
@ -193,9 +193,8 @@ int enc_open(void *opaque, const AVFrame *frame)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (ist) {
|
if (ist)
|
||||||
dec_ctx = ist->dec_ctx;
|
dec = ist->decoder;
|
||||||
}
|
|
||||||
|
|
||||||
// the timebase is chosen by filtering code
|
// the timebase is chosen by filtering code
|
||||||
if (ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO) {
|
if (ost->type == AVMEDIA_TYPE_AUDIO || ost->type == AVMEDIA_TYPE_VIDEO) {
|
||||||
@ -279,14 +278,16 @@ int enc_open(void *opaque, const AVFrame *frame)
|
|||||||
enc_ctx->width = ost->ist->par->width;
|
enc_ctx->width = ost->ist->par->width;
|
||||||
enc_ctx->height = ost->ist->par->height;
|
enc_ctx->height = ost->ist->par->height;
|
||||||
}
|
}
|
||||||
if (dec_ctx && dec_ctx->subtitle_header) {
|
|
||||||
|
av_assert0(dec);
|
||||||
|
if (dec->subtitle_header) {
|
||||||
/* ASS code assumes this buffer is null terminated so add extra byte. */
|
/* ASS code assumes this buffer is null terminated so add extra byte. */
|
||||||
enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1);
|
enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1);
|
||||||
if (!enc_ctx->subtitle_header)
|
if (!enc_ctx->subtitle_header)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
memcpy(enc_ctx->subtitle_header, dec_ctx->subtitle_header,
|
memcpy(enc_ctx->subtitle_header, dec->subtitle_header,
|
||||||
dec_ctx->subtitle_header_size);
|
dec->subtitle_header_size);
|
||||||
enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size;
|
enc_ctx->subtitle_header_size = dec->subtitle_header_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user