////////////////////////////////////////////////////////////////////////////
///
/// Attach a coded buffer to the deocded buffer
/// In case of transcoding is required, attach also
/// the transcoded buffer to the original coded buffer
///
void Codec_MmeAudioDtshd_c::AttachCodedFrameBuffer(void)
{
	Codec_MmeAudio_c::AttachCodedFrameBuffer();
	if (TranscodeEnable)
	{
		Buffer_t CodedDataBuffer;
		BufferStatus_t Status;
		Status = CurrentDecodeBuffer->ObtainAttachedBufferReference(CodedFrameBufferType, &CodedDataBuffer);
		if (Status != BufferNoError)
		{
			CODEC_ERROR("Could not get the attached coded data buffer (%d)\n", Status);
			return;
		}
		CodedDataBuffer->AttachBuffer(CurrentTranscodeBuffer);
		CurrentTranscodeBuffer->DecrementReferenceCount();
		// the transcoded buffer is now only referenced by its attachement to the coded buffer
	}
}
示例#2
0
CodecStatus_t   Codec_DvpVideo_c::Input(Buffer_t CodedBuffer)
{
	CodecStatus_t            Status;
	unsigned int             CodedDataLength;
	StreamInfo_t            *StreamInfo;
	Buffer_t             MarkerBuffer;
	BufferStructure_t        BufferStructure;
	ParsedFrameParameters_t     *ParsedFrameParameters;
	ParsedVideoParameters_t     *ParsedVideoParameters;
	Buffer_t             CapturedBuffer;
	ParsedVideoParameters_t     *CapturedParsedVideoParameters;
	//
	// Extract the useful coded data information
	//
	Status      = CodedBuffer->ObtainDataReference(NULL, &CodedDataLength, (void **)(&StreamInfo), CachedAddress);
	if (Status != PlayerNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Unable to obtain data reference.\n");
		return Status;
	}
	Status      = CodedBuffer->ObtainMetaDataReference(Player->MetaDataParsedFrameParametersType, (void **)(&ParsedFrameParameters));
	if (Status != PlayerNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Unable to obtain the meta data \"ParsedFrameParameters\".\n");
		return Status;
	}
	Status      = CodedBuffer->ObtainMetaDataReference(Player->MetaDataParsedVideoParametersType, (void**)&ParsedVideoParameters);
	if (Status != PlayerNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Unable to obtain the meta data \"ParsedVideoParameters\".\n");
		return Status;
	}
	//
	// Handle the special case of a marker frame
	//
	if ((CodedDataLength == 0) && !ParsedFrameParameters->NewStreamParameters && !ParsedFrameParameters->NewFrameParameters)
	{
		//
		// Get a marker buffer
		//
		memset(&BufferStructure, 0x00, sizeof(BufferStructure_t));
		BufferStructure.Format  = FormatMarkerFrame;
		Status      = Manifestor->GetDecodeBuffer(&BufferStructure, &MarkerBuffer);
		if (Status != ManifestorNoError)
		{
			report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Failed to get marker decode buffer from manifestor.\n");
			return Status;
		}
		MarkerBuffer->TransferOwnership(IdentifierCodec);
		Status      = MarkerBuffer->AttachMetaData(Player->MetaDataParsedFrameParametersReferenceType, UNSPECIFIED_SIZE, (void *)ParsedFrameParameters);
		if (Status != PlayerNoError)
		{
			report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Unable to attach a reference to \"ParsedFrameParameters\" to the marker buffer.\n");
			return Status;
		}
		MarkerBuffer->AttachBuffer(CodedBuffer);
		//
		// Queue/pass on the buffer
		//
		OutputRing->Insert((uintptr_t)MarkerBuffer);
		return CodecNoError;
	}
	//
	// Attach the coded data fields to the decode/captured buffer
	//
	CapturedBuffer  = (Buffer_t)StreamInfo->buffer_class;
	if (CapturedBuffer == NULL)
	{
		report(severity_fatal, "Codec_DvpVideo_c::Input(DVP) - NULL Buffer\n");
		return CodecNoError;
	}
//
	Status      = CapturedBuffer->ObtainMetaDataReference(Player->MetaDataParsedVideoParametersType, (void**)&CapturedParsedVideoParameters);
	if (Status != PlayerNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Unable to obtain the meta data \"ParsedVideoParameters\" from the captured buffer.\n");
		return Status;
	}
	memcpy(CapturedParsedVideoParameters, ParsedVideoParameters, sizeof(ParsedVideoParameters_t));
//
	Status      = CapturedBuffer->AttachMetaData(Player->MetaDataParsedFrameParametersReferenceType, UNSPECIFIED_SIZE, (void *)ParsedFrameParameters);
	if (Status != BufferNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Failed to attach Frame Parameters\n");
		return Status;
	}
	//
	// Switch the ownership hierarchy, and allow the captured buffer to exist on it's own.
	//
	CapturedBuffer->IncrementReferenceCount();
	Status  = CodedBuffer->DetachBuffer(CapturedBuffer);
	if (Status != BufferNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Failed to detach captured buffer from coded frame buffer\n");
		return Status;
	}
	Status      = CapturedBuffer->AttachBuffer(CodedBuffer);
	if (Status != BufferNoError)
	{
		report(severity_error, "Codec_DvpVideo_c::Input(DVP) - Failed to attach captured buffer to Coded Frame Buffer\n");
		return Status;
	}
	//
	// Pass the captured buffer on
	//
	OutputRing->Insert((uintptr_t)CapturedBuffer);
	return CodecNoError;
}