diff options
Diffstat (limited to 'audio/decode/ad_spdif.c')
-rw-r--r-- | audio/decode/ad_spdif.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 49b7d9a0d8..f4fc430208 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -84,9 +84,7 @@ static int codecs[] = { static int init(sh_audio_t *sh, const char *decoder) { - int x, in_size, srate, bps, *dtshd_rate; - unsigned char *start; - double pts; + int srate, bps, *dtshd_rate; AVFormatContext *lavf_ctx = NULL; AVStream *stream = NULL; const AVOption *opt = NULL; @@ -125,16 +123,8 @@ static int init(sh_audio_t *sh, const char *decoder) goto fail; } - // get sample_rate & bitrate from parser - x = ds_get_packet_pts(sh->ds, &start, &pts); - in_size = x; - if (x <= 0) { - pts = MP_NOPTS_VALUE; - x = 0; - } srate = 48000; //fake value bps = 768000/8; //fake value - sh->ds->buffer_pos -= in_size; int num_channels = 0; switch (lavf_ctx->streams[0]->codec->codec_id) { @@ -214,42 +204,24 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, struct spdifContext *spdif_ctx = sh->context; AVFormatContext *lavf_ctx = spdif_ctx->lavf_ctx; AVPacket pkt; - double pts; - int ret, in_size, consumed, x; - unsigned char *start = NULL; - consumed = spdif_ctx->out_buffer_len = 0; + spdif_ctx->out_buffer_len = 0; spdif_ctx->out_buffer_size = maxlen; spdif_ctx->out_buffer = buf; while (spdif_ctx->out_buffer_len + spdif_ctx->iec61937_packet_size < maxlen && spdif_ctx->out_buffer_len < minlen) { - if (sh->ds->eof) + struct demux_packet *mpkt = demux_read_packet(sh->gsh); + if (!mpkt) break; - x = ds_get_packet_pts(sh->ds, &start, &pts); - if (x <= 0) { - continue; // END_NOT_FOUND - } else { - in_size = x; - consumed = x; - if (x == 0) { - mp_msg(MSGT_DECAUDIO,MSGL_V, - "start[%p] in_size[%d] consumed[%d] x[%d].\n", - start, in_size, consumed, x); - continue; // END_NOT_FOUND - } - sh->ds->buffer_pos -= in_size - consumed; - } - av_init_packet(&pkt); - pkt.data = start; - pkt.size = x; - mp_msg(MSGT_DECAUDIO,MSGL_V, - "start[%p] pkt.size[%d] in_size[%d] consumed[%d] x[%d].\n", - start, pkt.size, in_size, consumed, x); - if (pts != MP_NOPTS_VALUE) { - sh->pts = pts; + mp_set_av_packet(&pkt, mpkt); + mp_msg(MSGT_DECAUDIO,MSGL_V, "pkt.data[%p] pkt.size[%d]\n", + pkt.data, pkt.size); + if (mpkt->pts != MP_NOPTS_VALUE) { + sh->pts = mpkt->pts; sh->pts_bytes = 0; } - ret = lavf_ctx->oformat->write_packet(lavf_ctx, &pkt); + int ret = lavf_ctx->oformat->write_packet(lavf_ctx, &pkt); + talloc_free(mpkt); if (ret < 0) break; } @@ -259,15 +231,6 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf, static int control(sh_audio_t *sh, int cmd, void *arg) { - unsigned char *start; - double pts; - - switch (cmd) { - case ADCTRL_RESYNC_STREAM: - case ADCTRL_SKIP_FRAME: - ds_get_packet_pts(sh->ds, &start, &pts); - return CONTROL_TRUE; - } return CONTROL_UNKNOWN; } |