FFMPEG plugin: Use member variables instead of local ones.

- 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 <coling@gmx.de>
(cherry picked from commit f2da1e752458b926aebe50642bf6af19e9903f17)
This commit is contained in:
Colin Günther 2014-07-12 13:41:04 +02:00
parent 384eec8fb3
commit 9e52cc7480

View File

@ -4,6 +4,7 @@
* Copyright (C) 2001 Axel Dörfler * Copyright (C) 2001 Axel Dörfler
* Copyright (C) 2004 Marcus Overhagen * Copyright (C) 2004 Marcus Overhagen
* Copyright (C) 2009 Stephan Amßus <superstippi@gmx.de> * Copyright (C) 2009 Stephan Amßus <superstippi@gmx.de>
* Copyright (C) 2014 Colin Günther <coling@gmx.de>
* *
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*/ */
@ -637,10 +638,9 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount,
{ {
bool firstRun = true; bool firstRun = true;
while (true) { while (true) {
const void* data;
size_t size;
media_header chunkMediaHeader; media_header chunkMediaHeader;
status_t err = GetNextChunk(&data, &size, &chunkMediaHeader); status_t err = GetNextChunk(&fChunkBuffer, &fChunkBufferSize,
&chunkMediaHeader);
if (err != B_OK) { if (err != B_OK) {
TRACE("AVCodecDecoder::_DecodeVideo(): error from " TRACE("AVCodecDecoder::_DecodeVideo(): error from "
"GetNextChunk(): %s\n", strerror(err)); "GetNextChunk(): %s\n", strerror(err));
@ -648,8 +648,8 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount,
} }
#ifdef LOG_STREAM_TO_FILE #ifdef LOG_STREAM_TO_FILE
if (sDumpedPackets < 100) { if (sDumpedPackets < 100) {
sStreamLogFile.Write(data, size); sStreamLogFile.Write(fChunkBuffer, fChunkBufferSize);
printf("wrote %ld bytes\n", size); printf("wrote %ld bytes\n", fChunkBufferSize);
sDumpedPackets++; sDumpedPackets++;
} else if (sDumpedPackets == 100) } else if (sDumpedPackets == 100)
sStreamLogFile.Unset(); sStreamLogFile.Unset();
@ -687,8 +687,8 @@ AVCodecDecoder::_DecodeVideo(void* outBuffer, int64* outFrameCount,
// packet buffers are supposed to contain complete frames only so we // packet buffers are supposed to contain complete frames only so we
// don't seem to be required to buffer any packets because not the // don't seem to be required to buffer any packets because not the
// complete packet has been read. // complete packet has been read.
fTempPacket.data = (uint8_t*)data; fTempPacket.data = (uint8_t*)fChunkBuffer;
fTempPacket.size = size; fTempPacket.size = fChunkBufferSize;
int gotPicture = 0; int gotPicture = 0;
int len = avcodec_decode_video2(fContext, fInputPicture, &gotPicture, int len = avcodec_decode_video2(fContext, fInputPicture, &gotPicture,
&fTempPacket); &fTempPacket);