Ejemplo n.º 1
0
int DecoderHelper::SetVideoDecoderParam(int width, int height, int codec, int format)
{
	if (_width != width || _height != height || _codec != codec)
	{
		releaseVideoDecoder();
	}

	if (NULL != _videoCodecContext)
	{
		return -1;
	}

	AVCodec	*avcodec = avcodec_find_decoder((AVCodecID)codec);
	if (NULL == avcodec)
	{
		return -1;
	}

	_videoCodecContext = avcodec_alloc_context3(avcodec);
	_videoCodecContext->pix_fmt = AV_PIX_FMT_YUV420P;
	_videoCodecContext->width   = width;
	_videoCodecContext->height  = height;

	int ret = avcodec_open2(_videoCodecContext, avcodec, NULL);
	if (ret < 0)
	{
		goto $fail;
	}

	int numBytes = avpicture_get_size(AV_PIX_FMT_YUV420P, width, height);
	_buffYUV420 = (uint8_t *)av_malloc(numBytes * sizeof(uint8_t));
	_videoFrame420 = av_frame_alloc();
	if (avpicture_fill((AVPicture *)_videoFrame420, _buffYUV420, AV_PIX_FMT_YUV420P,
		_width, _height) < 0)
	{

	}

	av_init_packet(&_videoAVPacket);
	_width = width;
	_height = height;
	_codec = codec;
	_outputFormat = format;
	
	return 0;

$fail:
	{
		return -1;
	}

}
OMXVideoDecoderBase::~OMXVideoDecoderBase() {
    releaseVideoDecoder(mVideoDecoder);

    if (this->ports) {
        if (this->ports[INPORT_INDEX]) {
            delete this->ports[INPORT_INDEX];
            this->ports[INPORT_INDEX] = NULL;
        }

        if (this->ports[OUTPORT_INDEX]) {
            delete this->ports[OUTPORT_INDEX];
            this->ports[OUTPORT_INDEX] = NULL;
        }
    }
}
Ejemplo n.º 3
0
DecoderHelper::~DecoderHelper()
{
	releaseVideoDecoder();
}