Пример #1
0
OMX_ERRORTYPE WmvDecoder::DeInitFilter()
{
    pWMV9DFree (&sDecObj);
    FreeDecoderMemory();
    FreeFrameBuffer();
    eWmvDecState = WMVDEC_LOADED;

    return OMX_ErrorNone;
}
Пример #2
0
OMX_ERRORTYPE WmvDecoder::InitFilter()
{
    int status = E_WMV9D_SUCCESS;


    printf("%s\n", pWMV9DecCodecVersionInfo());

    status = pWMV9DQuerymem (&sDecObj, sInFmt.nFrameHeight, sInFmt.nFrameWidth);
    if(E_WMV9D_SUCCESS != status)
        return OMX_ErrorUndefined;

    if(OMX_ErrorNone != AllocateDecoderMemory())
        return OMX_ErrorInsufficientResources;

    sDecObj.pfCbkBuffRead = WmvDecGetBitstream;
    sDecObj.pvAppContext = this;
    sDecObj.sDecParam.eCompressionFormat = eFormat;
    sDecObj.sDecParam.s32FrameRate   = sInFmt.xFramerate / Q16_SHIFT;
    sDecObj.sDecParam.s32BitRate     = sInFmt.nBitrate;
    sDecObj.sDecParam.u16FrameWidth  = (WMV9D_U16)sInFmt.nFrameWidth;
    sDecObj.sDecParam.u16FrameHeight = (WMV9D_U16)sInFmt.nFrameHeight;
    sDecObj.sDecParam.sOutputBuffer.tOutputFormat  = IYUV_WMV_PADDED;

    if(OMX_ErrorNone != AllocateFrameBuffer()) {
        FreeDecoderMemory();
        return OMX_ErrorInsufficientResources;
    }

    status = pWMV9DInit (&sDecObj);
    if(status != E_WMV9D_SUCCESS) {
        FreeFrameBuffer();
        FreeDecoderMemory();
        return OMX_ErrorUndefined;
    }

    eWmvDecState = WMVDEC_RUN;

    return OMX_ErrorNone;
}
Пример #3
0
static void DecodeDirac (const char *iname, const char *oname)
{
    clock_t start_t, stop_t;
    dirac_decoder_t *decoder = NULL;
    FILE *ifp;
    FILE *fpdata;
    unsigned char buffer[8192];
    int bytes = 0;
    int num_frames = 0;
    char infile_name[FILENAME_MAX];
    char outfile_hdr[FILENAME_MAX];
    char outfile_data[FILENAME_MAX];
    dirac_decoder_state_t state = STATE_BUFFER;

    strncpy(infile_name, iname, sizeof(infile_name));

    strncpy(outfile_data, oname, sizeof(outfile_data));

    if ((ifp = fopen (infile_name, "rb")) ==NULL)
    {
        perror(iname);
        return;
    }

    if ((fpdata = fopen (outfile_data, "wb")) ==NULL)
    {
        perror(outfile_hdr);
        fclose(ifp);
        return;
    }

    /* initialise the decoder */
    decoder = dirac_decoder_init(verbose);

    assert (decoder != NULL);


    start_t=clock();
    do
    {
        /* parse the input data */
        state = dirac_parse(decoder);

        switch (state)
        {
        case STATE_BUFFER:
            /*
            * parser is out of data. Read data from input stream and pass it
            * on to the parser
            */
            bytes = fread (buffer, 1, sizeof(buffer), ifp);
            if (bytes)
                dirac_buffer (decoder, buffer, buffer + bytes);
            break;

        case STATE_SEQUENCE:
            {
            /*
            * Start of sequence detected. Allocate for the frame buffers and
            * pass this buffer to the parser
            */
            unsigned char *buf[3];

            if (verbose)
            {
                fprintf (stdout, "\nSEQUENCE : major_ver=%d minor_version=%d profile=%d level=%d width=%d height=%d chroma=%s chroma_width=%d chroma_height=%d frame_rate=%d/%d, source_sampling=%s topfieldfirst=%s",
                decoder->parse_params.major_ver,
                decoder->parse_params.minor_ver,
                decoder->parse_params.profile,
                decoder->parse_params.level,
                decoder->src_params.width,
                decoder->src_params.height,
                chroma2string(decoder->src_params.chroma),
                decoder->src_params.chroma_width,
                decoder->src_params.chroma_height,
                decoder->src_params.frame_rate.numerator,
                decoder->src_params.frame_rate.denominator,
                decoder->src_params.source_sampling == 0 ? "progressive" :
                ( decoder->src_params.source_sampling == 1 ? "interlaced" : "UNKNOWN" ),
                decoder->src_params.topfieldfirst ? "yes" : "no");
            }

            FreeFrameBuffer(decoder);

            buf[0] = buf[1] = buf[2] = 0;

            buf[0] = (unsigned char *)malloc (decoder->src_params.width * decoder->src_params.height);
            buf[1] = (unsigned char *)malloc (decoder->src_params.chroma_width * decoder->src_params.chroma_height);
            buf[2] = (unsigned char *)malloc (decoder->src_params.chroma_width * decoder->src_params.chroma_height);
            dirac_set_buf (decoder, buf, NULL);


            }
            break;

        case STATE_SEQUENCE_END:
            /*
            * End of Sequence detected. Free the frame buffers
            */
            if (verbose)
                fprintf (stdout, "\nSEQUENCE_END");

            FreeFrameBuffer(decoder);
            break;

        case STATE_PICTURE_AVAIL:
            num_frames++;
            if (verbose)
            {
                fprintf (stdout, "\nFRAME_AVAIL : frame_num=%d",
                    decoder->frame_num);
            }
            /* picture available for display */
            if (!WritePicData(decoder, fpdata))
            {
                perror("Write failed");
                goto cleanup;
            }
            break;

        case STATE_INVALID:
            /* Invalid state. Stop all processing */
            fprintf (stderr, "Error processing file %s\n", iname);
            break;

        default:
            continue;
        }
    } while (bytes > 0 && state != STATE_INVALID);
cleanup:
    stop_t=clock();

    if ( verbose )
        fprintf (stdout, "\nTime per frame: %g",
                (double)(stop_t-start_t)/(double)(CLOCKS_PER_SEC*num_frames));

    fclose(fpdata);
    fclose(ifp);

    /* free all resources */
    FreeFrameBuffer(decoder);
    dirac_decoder_close(decoder);
}