?? video_decoder.c
字號:
/* * video_decoder.c *//* Standard Linux headers */#include <stdio.h> // always include stdio.h#include <stdlib.h> // always include stdlib.h#include <string.h> // defines memset and memcpy methods/* Codec Engine headers */#include <xdc/std.h> // xdc base definitions. Must come 1st#include <ti/sdo/ce/Engine.h> // required for any CE application#include <ti/sdo/ce/video/viddec.h> // defines video decoder methods/* Application headers */#include "debug.h" // DBG and ERR macros#include "video_decoder.h" // video decoder definitions, must be included // after codec engine headers!/* Macro for clearing structures */#define CLEAR(x) memset (&(x), 0, sizeof (x))/****************************************************************************** * video_decoder_setup ******************************************************************************//* input parameters: *//* Engine_Handle engineHandle -- handle to the codec engine *//* char *decoderName -- name of video decoder to create *//* VIDDEC_Handle *decoderHandleByRef -- video decoder handle passed by *//* reference, used to return the handle of *//* the decoder created by this function. *//* *//* *//* return value: *//* int -- VDEC_SUCCESS or VDEC_FAILURE as defined in video_decoder.h *//* *//******************************************************************************/int video_decoder_setup(Engine_Handle engineHandle, char *decoderName, VIDDEC_Handle *decoderHandleByRef){ VIDDEC_Handle decoderHandle; // handle to the video decoder instance /* Create video decoder instance */ decoderHandle = VIDDEC_create(engineHandle, decoderName, NULL); if (decoderHandle == NULL) { ERR("Can't open decode algorithm: %s\n", decoderName); return VDEC_FAILURE; } DBG("Created video decoder instance of %s\n", decoderName); DBG("\tWith handle %p\n", decoderHandle); DBG("\tUsing default static and dynamic parameters\n"); /* return the decoder instance handle through the provided pointer */ *decoderHandleByRef = decoderHandle; /* indicate successful completion of function with return value */ return VDEC_SUCCESS;}/****************************************************************************** * decode_video ******************************************************************************//* input parameters: *//* VIDDEC_Handle decoderHandle -- handle to the speech decoder as *//* returned by video_decoder_setup *//* char *inputBuffer -- pointer to buffer of input data *//* int inputSize -- size of inputBuffer in bytes *//* char *outputBuffer -- pointer to output buffer *//* int outputSize -- size of outputBuffer in bytes *//* *//* *//* return value: *//* int -- VDEC_SUCCESS or VDEC_FAILURE as defined in video_decoder.h *//* *//******************************************************************************/int decode_video(VIDDEC_Handle decoderHandle, char *inputBuffer, int inputSize, char *outputBuffer, int outputSize){/* Declare arguments and return value for VIDDEC_process */ VIDDEC_InArgs inArgs; // input args for VIDDEC_process VIDDEC_OutArgs outArgs; // output (return) from VIDDEC_process XDM_BufDesc inBufDesc; // buffer descriptor for input buffer XDM_BufDesc outBufDesc; // buffer descriptor for output buffer XDAS_Int32 status; // success or failure for VIDDEC_process/* Declare buffer descriptor elements */ XDAS_Int32 inputSizeArray[1]; // pointed to by inBufDesc.bufSizes XDAS_Int32 outputSizeArray[1]; // pointed to by outBufDesc.bufSizes/* Fill in input buffer descriptor */ inputSizeArray[0] = inputSize; inBufDesc.numBufs = 1; // one input buffer inBufDesc.bufSizes = inputSizeArray; // of this size inBufDesc.bufs = (XDAS_Int8 **) &inputBuffer; // located here/* Fill in output buffer descriptor */ outputSizeArray[0] = outputSize; outBufDesc.numBufs = 1; // one output buffer outBufDesc.bufSizes = outputSizeArray; // of this size outBufDesc.bufs = (XDAS_Int8 **) &outputBuffer; // located here/* Fill in input arguments structure */ inArgs.size = sizeof(VIDDEC_InArgs); inArgs.numBytes = inputSize; inArgs.inputID = 0;/* Specify size of output arguments (return) structure */ outArgs.size = sizeof(VIDDEC_OutArgs); /* Decode video buffer */ status = VIDDEC_process(decoderHandle, &inBufDesc, &outBufDesc, &inArgs, &outArgs); if (status != VIDDEC_EOK) { ERR("VIDDEC_process() failed with a fatal error (%ld ext: %#lx\n", status, outArgs.extendedError); return VDEC_FAILURE; } /* return VDEC_SUCCESS if video decoder executes correctly */ return VDEC_SUCCESS;}/****************************************************************************** * video_decoder_cleanup ******************************************************************************//* input parameters: *//* AUDDEC_Handle decoderHandle -- handle to the video decoder as *//* returned by video_decoder_setup *//* *//* *//* return value: *//* int -- always returns VDEC_SUCCESS as defined in video_decoder.h *//* *//******************************************************************************/int video_decoder_cleanup(VIDDEC_Handle decoderHandle){ VIDDEC_Status status; VIDDEC_DynamicParams dynParams; /* Zero out the status and dynParams structures */ CLEAR(status); CLEAR(dynParams); /* Set size field of status and dynParams */ status.size = sizeof(VIDDEC_Status); dynParams.size = sizeof(VIDDEC_DynamicParams); /* Query decoder for status */ VIDDEC_control(decoderHandle, XDM_GETSTATUS, &dynParams, &status); /* Delete decoder instance */ VIDDEC_delete(decoderHandle); /* Report any errors */ if(status.extendedError){ ERR("Deleted video decoder instance with handle %#0lx\n", (unsigned long) decoderHandle); ERR("\tDecoder exited with error mask %#0x\n", (unsigned int) status.extendedError ); } else{ DBG("Deleted video decoder instance with handle %#0lx\n", (unsigned long) decoderHandle); DBG("\tDecoder exited with no errors\n"); } /* Return success */ return VDEC_SUCCESS;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -