From c701a3ad4a6045766296ff0fc6ee4b4198c6969b Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Tue, 16 Feb 2016 13:14:05 +0100 Subject: [PATCH] Fix passthru of some eac3 tracks. --- MP42/MP42FormatUtilites.mm | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/MP42/MP42FormatUtilites.mm b/MP42/MP42FormatUtilites.mm index 1d18abf..4fd76cb 100644 --- a/MP42/MP42FormatUtilites.mm +++ b/MP42/MP42FormatUtilites.mm @@ -727,29 +727,30 @@ concatenate: return -2; } - /*if (!info->num_blocks) { - int ret; - if ((ret = av_copy_packet(&info->pkt, pkt)) < 0) - return ret; + if (!info->num_blocks) { + // Copy the frame + info->frame = (uint8_t *)malloc(size); + if (info->frame == NULL) { + return -2; + } + memcpy(info->frame, frame, size); + info->size = size; info->num_blocks = num_blocks; return 0; } else { - int ret; - if ((ret = av_grow_packet(&info->pkt, pkt->size)) < 0) - return ret; - memcpy(info->pkt.data + info->pkt.size - pkt->size, pkt->data, pkt->size); + info->frame = (uint8_t *)realloc(info->frame, info->size + size); + if (info->frame == NULL) { + return -2; + } + memcpy(info->frame + info->size, frame, size); + info->size += size; info->num_blocks += num_blocks; - info->pkt.duration += pkt->duration; - if ((ret = av_copy_packet_side_data(&info->pkt, pkt)) < 0) - return ret; - if (info->num_blocks != 6) + + if (info->num_blocks != 6) { return 0; - av_packet_unref(pkt); - if ((ret = av_copy_packet(pkt, &info->pkt)) < 0) - return ret; - av_packet_unref(&info->pkt); + } info->num_blocks = 0; - }*/ + } return 0; } @@ -787,5 +788,7 @@ CFDataRef createCookie_EAC3(void *context) } } + free(info->frame); + return CFDataCreate(kCFAllocatorDefault, cookie.GetBuffer(), cookie.GetBitPosition() / 8); }