From 9e52cc748084e62e6f1b6dc42038c84cde31f3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20G=C3=BCnther?= Date: Sat, 12 Jul 2014 13:41:04 +0200 Subject: [PATCH] FFMPEG plugin: Use member variables instead of local ones. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - This small refactoring is in preparation for implementing decoding of partial video frame data, where one needs to preserve encoded data between multiple calls to AVCodecDecoder::_DecodeVideo(). - Note: The names fChunkBuffer and fChunkBufferSize are open for discussion. I'd rather prefer fEncodedDataChunkBuffer and fEncodedDataChunkBufferSize. But I'd like to take small refactoring steps, and changing the naming would also touch the AVCodecDecoder::_DecodeAudio() function. I'd rather focus on improving the video part for now, leaving the audio part alone. - No functional change intended. Signed-off-by: Colin Günther (cherry picked from commit f2da1e752458b926aebe50642bf6af19e9903f17) --- .../media/plugins/ffmpeg/AVCodecDecoder.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp index 09e4205f75..e9cc2d41cf 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp @@ -4,6 +4,7 @@ * Copyright (C) 2001 Axel Dörfler * Copyright (C) 2004 Marcus Overhagen * Copyright (C) 2009 Stephan Amßus + * Copyright (C) 2014 Colin Günther * * All rights reserved. Distributed under the terms of the MIT License. */ @@ -637,10 +638,9 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount, { bool firstRun = true; while (true) { - const void* data; - size_t size; media_header chunkMediaHeader; - status_t err = GetNextChunk(&data, &size, &chunkMediaHeader); + status_t err = GetNextChunk(&fChunkBuffer, &fChunkBufferSize, + &chunkMediaHeader); if (err != B_OK) { TRACE("AVCodecDecoder::_DecodeVideo(): error from " "GetNextChunk(): %s\n", strerror(err)); @@ -648,8 +648,8 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount, } #ifdef LOG_STREAM_TO_FILE if (sDumpedPackets < 100) { - sStreamLogFile.Write(data, size); - printf("wrote %ld bytes\n", size); + sStreamLogFile.Write(fChunkBuffer, fChunkBufferSize); + printf("wrote %ld bytes\n", fChunkBufferSize); sDumpedPackets++; } else if (sDumpedPackets == 100) sStreamLogFile.Unset(); @@ -687,8 +687,8 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount, // packet buffers are supposed to contain complete frames only so we // don't seem to be required to buffer any packets because not the // complete packet has been read. - fTempPacket.data = (uint8_t*)data; - fTempPacket.size = size; + fTempPacket.data = (uint8_t*)fChunkBuffer; + fTempPacket.size = fChunkBufferSize; int gotPicture = 0; int len = avcodec_decode_video2(fContext, fInputPicture, &gotPicture, &fTempPacket);