From c12b5ffc33f8fb424b821afef1e060d7f6275844 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 15 Apr 2013 21:26:22 +0200 Subject: demux: get rid of sh_common_t The only reason this existed was the parsing code. Even though it could have been used for video, it's audio-only, so just move this to sh_audio_t. --- demux/demux.c | 21 ++++++++++----------- demux/stheader.h | 14 ++++---------- 2 files changed, 14 insertions(+), 21 deletions(-) (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index b3cb078dcb..9347f9a02c 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -45,7 +45,7 @@ #error MP_INPUT_BUFFER_PADDING_SIZE is too small! #endif -static void clear_parser(sh_common_t *sh); +static void clear_parser(sh_audio_t *sh); // Demuxer list extern const struct demuxer_desc demuxer_desc_edl; @@ -264,34 +264,35 @@ static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer, switch (sh->type) { case STREAM_VIDEO: { struct sh_video *sht = talloc_zero(demuxer, struct sh_video); + sht->gsh = sh; + sht->opts = sh->opts; sht->ds = demuxer->video; sh->video = sht; - sh->common_header = (struct sh_common *) sht; demuxer->v_streams[sh->stream_index] = sht; break; } case STREAM_AUDIO: { struct sh_audio *sht = talloc_zero(demuxer, struct sh_audio); + sht->gsh = sh; + sht->opts = sh->opts; sht->ds = demuxer->audio; sht->samplesize = 2; sht->sample_format = AF_FORMAT_S16_NE; sh->audio = sht; - sh->common_header = (struct sh_common *) sht; demuxer->a_streams[sh->stream_index] = sht; break; } case STREAM_SUB: { struct sh_sub *sht = talloc_zero(demuxer, struct sh_sub); + sht->gsh = sh; + sht->opts = sh->opts; sht->ds = demuxer->sub; sh->sub = sht; - sh->common_header = (struct sh_common *) sht; demuxer->s_streams[sh->stream_index] = sht; break; } default: assert(false); } - sh->common_header->opts = sh->opts; - sh->common_header->gsh = sh; return sh; } @@ -346,7 +347,6 @@ static void free_sh_sub(sh_sub_t *sh) { mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_sub at %p\n", sh); free(sh->extradata); - clear_parser((sh_common_t *)sh); free_sh_stream(sh->gsh); } @@ -375,7 +375,7 @@ static void free_sh_audio(demuxer_t *demuxer, int id) mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_audio at %p\n", sh); free(sh->wf); free(sh->codecdata); - clear_parser((sh_common_t *)sh); + clear_parser(sh); free_sh_stream(sh->gsh); } @@ -401,7 +401,6 @@ static void free_sh_video(sh_video_t *sh) { mp_msg(MSGT_DEMUXER, MSGL_DBG2, "DEMUXER: freeing sh_video at %p\n", sh); free(sh->bih); - clear_parser((sh_common_t *)sh); free_sh_stream(sh->gsh); } @@ -495,7 +494,7 @@ static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parse } } -static void get_parser(sh_common_t *sh, AVCodecContext **avctx, AVCodecParserContext **parser) +static void get_parser(sh_audio_t *sh, AVCodecContext **avctx, AVCodecParserContext **parser) { *avctx = NULL; *parser = NULL; @@ -523,7 +522,7 @@ int ds_parse(demux_stream_t *ds, uint8_t **buffer, int *len, double pts, int64_t return av_parser_parse2(parser, avctx, buffer, len, *buffer, *len, pts, pts, pos); } -static void clear_parser(sh_common_t *sh) +static void clear_parser(sh_audio_t *sh) { av_parser_close(sh->parser); sh->parser = NULL; diff --git a/demux/stheader.h b/demux/stheader.h index 47dcf7a207..7cb65b9bcc 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -48,8 +48,6 @@ struct sh_stream { int stream_index; // Demuxer specific ID (always set, defaults to tid). int demuxer_id; - // Abomination. - struct sh_common *common_header; // One of these is non-NULL, the others are NULL, depending on the stream // type. struct sh_audio *audio; @@ -86,20 +84,12 @@ struct sh_stream { /* number of seconds stream should be delayed \ * (according to dwStart or similar) */ \ float stream_delay; \ - /* things needed for parsing */ \ - bool needs_parsing; \ - struct AVCodecContext *avctx; \ - struct AVCodecParserContext *parser; \ /* audio: last known pts value in output from decoder \ * video: predicted/interpolated PTS of the current frame */ \ double pts; \ /* decoder context */ \ void *context; \ -typedef struct sh_common { - SH_COMMON -} sh_common_t; - typedef struct sh_audio { SH_COMMON // output format: @@ -129,6 +119,10 @@ typedef struct sh_audio { unsigned char *codecdata; int codecdata_len; int pts_bytes; // bytes output by decoder after last known pts + /* things needed for parsing */ + bool needs_parsing; + struct AVCodecContext *avctx; + struct AVCodecParserContext *parser; } sh_audio_t; typedef struct sh_video { -- cgit v1.2.3