diff options
-rw-r--r-- | audio/decode/ad_lavc.c | 11 | ||||
-rw-r--r-- | audio/decode/ad_spdif.c | 20 | ||||
-rw-r--r-- | demux/demux.c | 70 | ||||
-rw-r--r-- | demux/demux.h | 3 | ||||
-rw-r--r-- | demux/demux_rawaudio.c | 1 | ||||
-rw-r--r-- | demux/stheader.h | 4 |
6 files changed, 5 insertions, 104 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index b5a4ee1ef8..2495012e47 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -344,7 +344,6 @@ static int control(sh_audio_t *sh, int cmd, void *arg) switch (cmd) { case ADCTRL_RESYNC_STREAM: avcodec_flush_buffers(ctx->avctx); - ds_clear_parser(sh->ds); ctx->previous_data_left = 0; ctx->output_left = 0; return CONTROL_TRUE; @@ -384,10 +383,7 @@ static int decode_new_packet(struct sh_audio *sh) if (!mpkt) { assert(!priv->previous_data_left); start = NULL; - insize = 0; - ds_parse(sh->ds, &start, &insize, pts, 0); - if (insize <= 0) - return -1; // error or EOF + return -1; // error or EOF } else { assert(mpkt->len >= priv->previous_data_left); if (!priv->previous_data_left) { @@ -396,8 +392,7 @@ static int decode_new_packet(struct sh_audio *sh) } insize = priv->previous_data_left; start = mpkt->buffer + mpkt->len - priv->previous_data_left; - int consumed = ds_parse(sh->ds, &start, &insize, pts, 0); - priv->previous_data_left -= consumed; + priv->previous_data_left -= insize; priv->previous_data_left = FFMAX(priv->previous_data_left, 0); } @@ -420,7 +415,7 @@ static int decode_new_packet(struct sh_audio *sh) return -1; } // The "insize >= ret" test is sanity check against decoder overreads - if (!sh->parser && insize >= ret) + if (insize >= ret) priv->previous_data_left = insize - ret; if (!got_frame) return 0; diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 1314110062..49b7d9a0d8 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -132,20 +132,8 @@ static int init(sh_audio_t *sh, const char *decoder) pts = MP_NOPTS_VALUE; x = 0; } - ds_parse(sh->ds, &start, &x, pts, 0); srate = 48000; //fake value bps = 768000/8; //fake value - if (x && sh->avctx) { // we have parser and large enough buffer - if (sh->avctx->sample_rate < 44100) { - mp_msg(MSGT_DECAUDIO,MSGL_INFO, - "This stream sample_rate[%d Hz] may be broken. " - "Force reset 48000Hz.\n", - sh->avctx->sample_rate); - srate = 48000; //fake value - } else - srate = sh->avctx->sample_rate; - bps = sh->avctx->bit_rate/8; - } sh->ds->buffer_pos -= in_size; int num_channels = 0; @@ -239,14 +227,10 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, break; x = ds_get_packet_pts(sh->ds, &start, &pts); if (x <= 0) { - x = 0; - ds_parse(sh->ds, &start, &x, MP_NOPTS_VALUE, 0); - if (x == 0) - continue; // END_NOT_FOUND - in_size = x; + continue; // END_NOT_FOUND } else { in_size = x; - consumed = ds_parse(sh->ds, &start, &x, pts, 0); + consumed = x; if (x == 0) { mp_msg(MSGT_DECAUDIO,MSGL_V, "start[%p] in_size[%d] consumed[%d] x[%d].\n", diff --git a/demux/demux.c b/demux/demux.c index 3f5851e5b6..9d02abc8f1 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -46,8 +46,6 @@ #error MP_INPUT_BUFFER_PADDING_SIZE is too small! #endif -static void clear_parser(sh_audio_t *sh); - // Demuxer list extern const struct demuxer_desc demuxer_desc_edl; extern const struct demuxer_desc demuxer_desc_cue; @@ -370,7 +368,6 @@ 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); free_sh_stream(sh->gsh); } @@ -467,73 +464,6 @@ void ds_add_packet(demux_stream_t *ds, demux_packet_t *dp) ds->demuxer->video->packs); } -static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parser, const char *format) -{ - enum AVCodecID codec_id = mp_codec_to_av_codec_id(format); - - switch (codec_id) { - case AV_CODEC_ID_AAC_LATM: - case AV_CODEC_ID_AC3: - case AV_CODEC_ID_EAC3: - case AV_CODEC_ID_DTS: - case AV_CODEC_ID_FLAC: - case AV_CODEC_ID_MLP: - case AV_CODEC_ID_MP3: - case AV_CODEC_ID_MP2: - case AV_CODEC_ID_TRUEHD: - *avctx = avcodec_alloc_context3(NULL); - if (!*avctx) - return; - *parser = av_parser_init(codec_id); - if (!*parser) - av_freep(avctx); - break; - default: ; - } -} - -static void get_parser(sh_audio_t *sh, AVCodecContext **avctx, AVCodecParserContext **parser) -{ - *avctx = NULL; - *parser = NULL; - - if (!sh || !sh->needs_parsing) - return; - - *avctx = sh->avctx; - *parser = sh->parser; - if (*parser) - return; - - allocate_parser(avctx, parser, sh->gsh->codec); - sh->avctx = *avctx; - sh->parser = *parser; -} - -int ds_parse(demux_stream_t *ds, uint8_t **buffer, int *len, double pts, int64_t pos) -{ - AVCodecContext *avctx; - AVCodecParserContext *parser; - get_parser(ds->sh, &avctx, &parser); - if (!parser) - return *len; - return av_parser_parse2(parser, avctx, buffer, len, *buffer, *len, pts, pts, pos); -} - -static void clear_parser(sh_audio_t *sh) -{ - av_parser_close(sh->parser); - sh->parser = NULL; - av_freep(&sh->avctx); -} - -void ds_clear_parser(demux_stream_t *ds) -{ - if (!ds->sh) - return; - clear_parser(ds->sh); -} - void ds_read_packet(demux_stream_t *ds, stream_t *stream, int len, double pts, int64_t pos, bool keyframe) { diff --git a/demux/demux.h b/demux/demux.h index df73ddd4ee..a478e58409 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -292,9 +292,6 @@ int ds_get_packet_pts(struct demux_stream *ds, unsigned char **start, struct demux_packet *ds_get_packet_sub(demux_stream_t *ds); struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last); double ds_get_next_pts(struct demux_stream *ds); -int ds_parse(struct demux_stream *sh, uint8_t **buffer, int *len, double pts, - int64_t pos); -void ds_clear_parser(struct demux_stream *sh); struct demuxer *demux_open(struct MPOpts *opts, struct stream *stream, int file_format, int aid, int vid, int sid, diff --git a/demux/demux_rawaudio.c b/demux/demux_rawaudio.c index 3cd2500e03..b680a77888 100644 --- a/demux/demux_rawaudio.c +++ b/demux/demux_rawaudio.c @@ -70,7 +70,6 @@ static demuxer_t* demux_rawaudio_open(demuxer_t* demuxer) { demuxer->audio->id = 0; demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; - sh_audio->needs_parsing = 1; return demuxer; } diff --git a/demux/stheader.h b/demux/stheader.h index 475d063637..511e959c30 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -117,10 +117,6 @@ 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 { |