mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-27 01:42:20 +00:00
avformat/mpeg: Make VobSub demuxer have its own context struct
When the VobSub demuxer was added, the fields it required were simply
added to the MpegDemuxContext (if the VobSub demuxer was selected at
all). The mpeg demuxer of course doesn't use these fields even if they
are there; and the VobSub demuxer doesn't use the old ones: It opens an
mpeg subdemuxer of its own and uses this where a mpeg demuxer is
required. Hence the two contexts can be split, saving memory.
Furthermore several headers can now be moved to the section that is
guarded by #if CONFIG_VOBSUB_DEMUXER (this even includes avassert.h
which was unguarded and has been added in 9cde9f70
despite not being
used in that patch).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
d5274f86a8
commit
3f37880c05
@ -24,14 +24,6 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mpeg.h"
|
#include "mpeg.h"
|
||||||
|
|
||||||
#if CONFIG_VOBSUB_DEMUXER
|
|
||||||
# include "subtitles.h"
|
|
||||||
# include "libavutil/bprint.h"
|
|
||||||
# include "libavutil/opt.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libavutil/avassert.h"
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* demux code */
|
/* demux code */
|
||||||
|
|
||||||
@ -123,18 +115,12 @@ static int mpegps_probe(const AVProbeData *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef struct MpegDemuxContext {
|
typedef struct MpegDemuxContext {
|
||||||
AVClass *class;
|
|
||||||
int32_t header_state;
|
int32_t header_state;
|
||||||
unsigned char psm_es_type[256];
|
unsigned char psm_es_type[256];
|
||||||
int sofdec;
|
int sofdec;
|
||||||
int dvd;
|
int dvd;
|
||||||
int imkh_cctv;
|
int imkh_cctv;
|
||||||
int raw_ac3;
|
int raw_ac3;
|
||||||
#if CONFIG_VOBSUB_DEMUXER
|
|
||||||
AVFormatContext *sub_ctx;
|
|
||||||
FFDemuxSubtitlesQueue q[32];
|
|
||||||
char *sub_name;
|
|
||||||
#endif
|
|
||||||
} MpegDemuxContext;
|
} MpegDemuxContext;
|
||||||
|
|
||||||
static int mpegps_read_header(AVFormatContext *s)
|
static int mpegps_read_header(AVFormatContext *s)
|
||||||
@ -705,9 +691,21 @@ AVInputFormat ff_mpegps_demuxer = {
|
|||||||
|
|
||||||
#if CONFIG_VOBSUB_DEMUXER
|
#if CONFIG_VOBSUB_DEMUXER
|
||||||
|
|
||||||
|
#include "subtitles.h"
|
||||||
|
#include "libavutil/avassert.h"
|
||||||
|
#include "libavutil/bprint.h"
|
||||||
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
#define REF_STRING "# VobSub index file,"
|
#define REF_STRING "# VobSub index file,"
|
||||||
#define MAX_LINE_SIZE 2048
|
#define MAX_LINE_SIZE 2048
|
||||||
|
|
||||||
|
typedef struct VobSubDemuxContext {
|
||||||
|
const AVClass *class;
|
||||||
|
AVFormatContext *sub_ctx;
|
||||||
|
FFDemuxSubtitlesQueue q[32];
|
||||||
|
char *sub_name;
|
||||||
|
} VobSubDemuxContext;
|
||||||
|
|
||||||
static int vobsub_probe(const AVProbeData *p)
|
static int vobsub_probe(const AVProbeData *p)
|
||||||
{
|
{
|
||||||
if (!strncmp(p->buf, REF_STRING, sizeof(REF_STRING) - 1))
|
if (!strncmp(p->buf, REF_STRING, sizeof(REF_STRING) - 1))
|
||||||
@ -718,7 +716,7 @@ static int vobsub_probe(const AVProbeData *p)
|
|||||||
static int vobsub_read_header(AVFormatContext *s)
|
static int vobsub_read_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
int i, ret = 0, header_parsed = 0, langidx = 0;
|
int i, ret = 0, header_parsed = 0, langidx = 0;
|
||||||
MpegDemuxContext *vobsub = s->priv_data;
|
VobSubDemuxContext *vobsub = s->priv_data;
|
||||||
size_t fname_len;
|
size_t fname_len;
|
||||||
char *header_str = NULL;
|
char *header_str = NULL;
|
||||||
AVBPrint header;
|
AVBPrint header;
|
||||||
@ -911,7 +909,7 @@ end:
|
|||||||
|
|
||||||
static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
|
static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
MpegDemuxContext *vobsub = s->priv_data;
|
VobSubDemuxContext *vobsub = s->priv_data;
|
||||||
FFDemuxSubtitlesQueue *q;
|
FFDemuxSubtitlesQueue *q;
|
||||||
AVIOContext *pb = vobsub->sub_ctx->pb;
|
AVIOContext *pb = vobsub->sub_ctx->pb;
|
||||||
int ret, psize, total_read = 0, i;
|
int ret, psize, total_read = 0, i;
|
||||||
@ -999,7 +997,7 @@ fail:
|
|||||||
static int vobsub_read_seek(AVFormatContext *s, int stream_index,
|
static int vobsub_read_seek(AVFormatContext *s, int stream_index,
|
||||||
int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
|
int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
|
||||||
{
|
{
|
||||||
MpegDemuxContext *vobsub = s->priv_data;
|
VobSubDemuxContext *vobsub = s->priv_data;
|
||||||
|
|
||||||
/* Rescale requested timestamps based on the first stream (timebase is the
|
/* Rescale requested timestamps based on the first stream (timebase is the
|
||||||
* same for all subtitles stream within a .idx/.sub). Rescaling is done just
|
* same for all subtitles stream within a .idx/.sub). Rescaling is done just
|
||||||
@ -1031,8 +1029,8 @@ static int vobsub_read_seek(AVFormatContext *s, int stream_index,
|
|||||||
|
|
||||||
static int vobsub_read_close(AVFormatContext *s)
|
static int vobsub_read_close(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
|
VobSubDemuxContext *vobsub = s->priv_data;
|
||||||
int i;
|
int i;
|
||||||
MpegDemuxContext *vobsub = s->priv_data;
|
|
||||||
|
|
||||||
for (i = 0; i < s->nb_streams; i++)
|
for (i = 0; i < s->nb_streams; i++)
|
||||||
ff_subtitles_queue_clean(&vobsub->q[i]);
|
ff_subtitles_queue_clean(&vobsub->q[i]);
|
||||||
@ -1042,7 +1040,7 @@ static int vobsub_read_close(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const AVOption options[] = {
|
static const AVOption options[] = {
|
||||||
{ "sub_name", "URI for .sub file", offsetof(MpegDemuxContext, sub_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
|
{ "sub_name", "URI for .sub file", offsetof(VobSubDemuxContext, sub_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1056,7 +1054,7 @@ static const AVClass vobsub_demuxer_class = {
|
|||||||
AVInputFormat ff_vobsub_demuxer = {
|
AVInputFormat ff_vobsub_demuxer = {
|
||||||
.name = "vobsub",
|
.name = "vobsub",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("VobSub subtitle format"),
|
.long_name = NULL_IF_CONFIG_SMALL("VobSub subtitle format"),
|
||||||
.priv_data_size = sizeof(MpegDemuxContext),
|
.priv_data_size = sizeof(VobSubDemuxContext),
|
||||||
.read_probe = vobsub_probe,
|
.read_probe = vobsub_probe,
|
||||||
.read_header = vobsub_read_header,
|
.read_header = vobsub_read_header,
|
||||||
.read_packet = vobsub_read_packet,
|
.read_packet = vobsub_read_packet,
|
||||||
|
Loading…
Reference in New Issue
Block a user