From 54437f9030fed58baedc46f211baeb88282ef883 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Sat, 23 Jul 2016 12:42:55 +0200 Subject: [PATCH] Remove deprecated ffmpeg api --- MP42/MP42BitmapSubConverter.h | 5 ++--- MP42/MP42BitmapSubConverter.m | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/MP42/MP42BitmapSubConverter.h b/MP42/MP42BitmapSubConverter.h index 2904d7f..985d0a1 100644 --- a/MP42/MP42BitmapSubConverter.h +++ b/MP42/MP42BitmapSubConverter.h @@ -26,15 +26,14 @@ NS_ASSUME_NONNULL_BEGIN CIContext *_imgContext; AVCodec *avCodec; AVCodecContext *avContext; - AVSubtitle subtitle; MP42Fifo *_inputSamplesBuffer; MP42Fifo *_outputSamplesBuffer; UInt32 paletteG[16]; - NSData *srcMagicCookie; + NSData *srcMagicCookie; - uint8_t *codecData; + uint8_t *codecData; unsigned int bufferSize; int32_t _readerDone; diff --git a/MP42/MP42BitmapSubConverter.m b/MP42/MP42BitmapSubConverter.m index 12dfed2..3d1d961 100644 --- a/MP42/MP42BitmapSubConverter.m +++ b/MP42/MP42BitmapSubConverter.m @@ -166,6 +166,7 @@ void FFInitFFmpeg() { } AVPacket pkt; + AVSubtitle subtitle; av_init_packet(&pkt); pkt.data = codecData; pkt.size = bufferSize; @@ -208,10 +209,10 @@ void FFInitFFmpeg() { uint8_t *imageData = calloc(rect->w * rect->h * 4, sizeof(uint8_t)); uint8_t *line = (uint8_t *)imageData; - uint8_t *sub = rect->pict.data[0]; + uint8_t *sub = rect->data[0]; unsigned int w = rect->w; unsigned int h = rect->h; - uint32_t *palette = (uint32_t *)rect->pict.data[1]; + uint32_t *palette = (uint32_t *)rect->data[1]; if (usePalette) { for (unsigned int j = 0; j < 4; j++) @@ -226,7 +227,7 @@ void FFInitFFmpeg() { } line += rect->w*4; - sub += rect->pict.linesize[0]; + sub += rect->linesize[0]; } // Kill the alpha @@ -275,7 +276,7 @@ void FFInitFFmpeg() { } avsubtitle_free(&subtitle); - av_free_packet(&pkt); + av_packet_unref(&pkt); [sampleBuffer release]; } @@ -300,6 +301,7 @@ void FFInitFFmpeg() { } AVPacket pkt; + AVSubtitle subtitle; av_init_packet(&pkt); pkt.data = sampleBuffer->data; pkt.size = sampleBuffer->size; @@ -339,8 +341,8 @@ void FFInitFFmpeg() { uint8_t color; pixel = yy * rect->w + xx; - color = rect->pict.data[0][pixel]; - argb = ((uint32_t *)rect->pict.data[1])[color]; + color = rect->data[0][pixel]; + argb = ((uint32_t *)rect->data[1])[color]; imageData[yy * rect->w + xx] = EndianU32_BtoN(argb); } @@ -392,7 +394,7 @@ void FFInitFFmpeg() { } avsubtitle_free(&subtitle); - av_free_packet(&pkt); + av_packet_unref(&pkt); [sampleBuffer release]; } @@ -497,15 +499,6 @@ void FFInitFFmpeg() { av_freep(&codecData); } - if (subtitle.rects) { - for (unsigned i = 0; i < subtitle.num_rects; i++) { - av_freep(&subtitle.rects[i]->pict.data[0]); - av_freep(&subtitle.rects[i]->pict.data[1]); - av_freep(&subtitle.rects[i]); - } - av_freep(&subtitle.rects); - } - [srcMagicCookie release]; [_outputSamplesBuffer release]; [_inputSamplesBuffer release];