From 7586a7f6746e97dab2b042e3e5eca429118e5bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 12 Aug 2007 21:07:44 +0000 Subject: [PATCH] For consistency, also do audio decoding I doubt it is needed since both AC3 and MPEG2AUDIO can figure out stream details, but lets keep it in there anyway --- pvr_rec.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/pvr_rec.c b/pvr_rec.c index b35bb8c1..44d0bdbb 100644 --- a/pvr_rec.c +++ b/pvr_rec.c @@ -699,9 +699,10 @@ pwo_writepkt(pvr_rec_t *pvrr, th_subscription_t *s, uint32_t startcode, AVStream *st, *stx; AVPacket pkt; uint8_t *pbuf; - int pbuflen, gotpic; + int pbuflen, data_size; char txt[100]; const char *tp; + void *abuf; AVFrame pic; if(stream_index == -1) @@ -762,10 +763,11 @@ pwo_writepkt(pvr_rec_t *pvrr, th_subscription_t *s, uint32_t startcode, break; case CODEC_TYPE_VIDEO: - r = avcodec_decode_video(st->codec, &pic, &gotpic, buf, len); - if(r != 0 && gotpic) { + r = avcodec_decode_video(st->codec, &pic, &data_size, buf, len); + if(r != 0 && data_size) { syslog(LOG_DEBUG, "pvr: \"%s\" - " - "Stream #%d: Decoded a complete frame: %d x %d in %.2fHz\n", + "Stream #%d: Decoded a complete video frame: " + "%d x %d in %.2fHz\n", pvrr->pvrr_printname, stream_index, st->codec->width, st->codec->height, (float)st->codec->time_base.den / @@ -773,13 +775,27 @@ pwo_writepkt(pvr_rec_t *pvrr, th_subscription_t *s, uint32_t startcode, pf->pids[streamidx].decoded = 1; pf->decode_ctd--; - break; + } + break; case CODEC_TYPE_AUDIO: - pf->pids[streamidx].decoded = 1; - pf->decode_ctd--; - break; + abuf = malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); + + r = avcodec_decode_audio(st->codec, abuf, &data_size, buf, len); + + free(abuf); + + if(r != 0 && data_size) { + syslog(LOG_DEBUG, "pvr: \"%s\" - " + "Stream #%d: Decoded a complete audio frame: " + "%d channels in %d Hz\n", + pvrr->pvrr_printname, stream_index, + st->codec->channels, + st->codec->sample_rate); + pf->pids[streamidx].decoded = 1; + pf->decode_ctd--; } + break; } }