Пример #1
0
/* 
  called during initialization and/or when xImage (decompressor)
  attributes change, note that nImage and src are actually
  synonymous and should be cleared out a bit (to say the least!)


  !!!!!!
  This function should be prepared to get data that is NOT of the 
  type native to the decoder,  It should do it's best to verify it 
  as valid data and should clean up after itself and return NULL
  if it doesn't recognize the format of the data
*/
static DXL_XIMAGE_HANDLE vp31_xImageReCreate(VP31_XIMAGE_HANDLE src,unsigned char *data,
	int type,enum BITDEPTH bitDepth,int w,int h)
{  
    DXL_XIMAGE_HANDLE vp31_xImageCreate(unsigned char *data);
	
    if (type != VP31_FOURCC) 
		return NULL;

	if (src != NULL)	/* if an xImage/decompressor already exists, destroy it */
		vp31_xImageDestroy(src);

	/* create a new xImage, specific to this type of decoder, 
        (see "VP31_XIMAGE" struct above and dxl_main.h) */

	src = (VP31_XIMAGE_HANDLE)duck_calloc(1,sizeof(VP31_XIMAGE),DMEM_GENERAL);

	if (!src) 
        return NULL;

//	duck_memset(nImage,0,sizeof(VP31_XIMAGE));

	/* set up the "vtable" of interface calls */
    src->create =  (DXL_XIMAGE_HANDLE (*)(void *)) vp31_xImageCreate;
    src->recreate =  (DXL_XIMAGE_HANDLE (*)(DXL_XIMAGE_HANDLE,void *,int,int,int,int)) vp31_xImageReCreate;

	src->destroy = (int (*)(DXL_XIMAGE_HANDLE))vp31_xImageDestroy;
	src->dx = (int (*)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE)) vp31_decompress;
	src->blit = NULL; /* there is no interleaved blitter for vp3x files */

    src->internalFormat = (int (*)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE)) vp31_GetXImageInternalFormat; 
	src->bdPrefs = bitDepths; /* plug in the list of prefered bit depths */

    src->addr = data;
    src->dkFlags.inUse = 1;

	src->imWidth = src->w = w ? w : 320;
	src->imHeight = src->h = h ? h : 240;

	src->myFourCC = VP31_FOURCC;
  
    /* create new PBI */
    if(!StartDecoder( &(src->myPBI), src->imWidth, src->imHeight ))
    {
		vp31_xImageDestroy(src);
        src = NULL;
    }

    return (DXL_XIMAGE_HANDLE ) src;
}
Пример #2
0
WeatherFaxWizard::WeatherFaxWizard( WeatherFaxImage &img,
                                    bool use_decoder, wxString decoder_filename,
                                    WeatherFax &parent,
                                    WeatherFaxImageCoordinateList *coords,
                                    wxString newcoordbasename)
    : WeatherFaxWizardBase( &parent ), m_decoder(*this, decoder_filename),
      m_DecoderOptionsDialog(use_decoder ? new DecoderOptionsDialog(*this) : NULL),
      m_parent(parent), m_wfimg(img), m_curCoords(img.m_Coords),
      m_NewCoordBaseName(newcoordbasename.empty() ? wxString(_("New Coord")) : newcoordbasename),
      m_Coords(coords ? *coords : m_BuiltinCoords)
{

    wxIcon icon;
    icon.CopyFromBitmap(*_img_weatherfax);
    SetIcon(icon);

    m_sPhasing->SetValue(m_wfimg.phasing);
    m_sSkew->SetValue(m_wfimg.skew);
    m_cFilter->SetSelection(m_wfimg.filter);

    /* reset image */
    if(!m_wfimg.m_origimg.Ok())
        m_wfimg.m_origimg.Create(1, 1); /* small image; so orig image is always ok to work with */
    
    MakeNewCoordinates();

    m_wfimg.MakePhasedImage();

    m_sPhasing->SetRange(0, m_wfimg.m_phasedimg.GetWidth()-1);
    m_swFaxArea1->SetScrollbars(1, 1, m_wfimg.m_phasedimg.GetWidth(), m_wfimg.m_phasedimg.GetHeight());
    
    m_cRotation->SetSelection(m_curCoords->rotation);

    if(use_decoder && m_decoder.m_inputtype != FaxDecoder::NONE) {
        m_DecoderOptionsDialog->SetIcon(icon);
        StartDecoder();
    } else {
        m_thDecoder = NULL;
        m_bStopDecoding->Disable();

        if(m_DecoderOptionsDialog)
            m_DecoderOptionsDialog->m_sMinusSaturationThreshold->Disable();
        else
            m_bDecoderOptions->Disable();
    }
}
Пример #3
0
bool COpenMaxVideo::Open(CDVDStreamInfo &hints)
{
  #if defined(OMX_DEBUG_VERBOSE)
  CLog::Log(LOGDEBUG, "%s::%s\n", CLASSNAME, __func__);
  #endif

  OMX_ERRORTYPE omx_err = OMX_ErrorNone;
  std::string decoder_name;

  m_decoded_width  = hints.width;
  m_decoded_height = hints.height;

  switch (hints.codec)
  {
    case CODEC_ID_H264:
    {
      switch(hints.profile)
      {
        case FF_PROFILE_H264_BASELINE:
          // (role name) video_decoder.avc
          // H.264 Baseline profile
          decoder_name = OMX_H264BASE_DECODER;
        break;
        case FF_PROFILE_H264_MAIN:
          // (role name) video_decoder.avc
          // H.264 Main profile
          decoder_name = OMX_H264MAIN_DECODER;
        break;
        case FF_PROFILE_H264_HIGH:
          // (role name) video_decoder.avc
          // H.264 Main profile
          decoder_name = OMX_H264HIGH_DECODER;
        break;
        default:
          return false;
        break;
      }
    }
    break;
    case CODEC_ID_MPEG4:
      // (role name) video_decoder.mpeg4
      // MPEG-4, DivX 4/5 and Xvid compatible
      decoder_name = OMX_MPEG4_DECODER;
    break;
    /*
    TODO: what mpeg4 formats are "ext" ????
    case NvxStreamType_MPEG4Ext:
      // (role name) video_decoder.mpeg4
      // MPEG-4, DivX 4/5 and Xvid compatible
      decoder_name = OMX_MPEG4EXT_DECODER;
      m_pFormatName = "omx-mpeg4";
    break;
    */
    case CODEC_ID_MPEG2VIDEO:
      // (role name) video_decoder.mpeg2
      // MPEG-2
      decoder_name = OMX_MPEG2V_DECODER;
    break;
    case CODEC_ID_VC1:
      // (role name) video_decoder.vc1
      // VC-1, WMV9
      decoder_name = OMX_VC1_DECODER;
    break;
    default:
      return false;
    break;
  }

  // initialize OpenMAX.
  if (!Initialize(decoder_name))
  {
    return false;
  }

  // TODO: Find component from role name.
  // Get the port information. This will obtain information about the
  // number of ports and index of the first port.
  OMX_PORT_PARAM_TYPE port_param;
  OMX_INIT_STRUCTURE(port_param);
  omx_err = OMX_GetParameter(m_omx_decoder, OMX_IndexParamVideoInit, &port_param);
  if (omx_err)
  {
    Deinitialize();
    return false;
  }
  m_omx_input_port = port_param.nStartPortNumber;
  m_omx_output_port = m_omx_input_port + 1;
  #if defined(OMX_DEBUG_VERBOSE)
  CLog::Log(LOGDEBUG,
    "%s::%s - decoder_component(0x%p), input_port(0x%x), output_port(0x%x)\n",
    CLASSNAME, __func__, m_omx_decoder, m_omx_input_port, m_omx_output_port);
  #endif

  // TODO: Set role for the component because components could have multiple roles.
  //QueryCodec();

  // Component will be in OMX_StateLoaded now so we can alloc omx input/output buffers.
  // we can only alloc them in OMX_StateLoaded state or if the component port is disabled
  // Alloc buffers for the omx input port.
  omx_err = AllocOMXInputBuffers();
  if (omx_err)
  {
    Deinitialize();
    return false;
  }
  // Alloc buffers for the omx output port.
  m_egl_display = g_Windowing.GetEGLDisplay();
  m_egl_context = g_Windowing.GetEGLContext();
  omx_err = AllocOMXOutputBuffers();
  if (omx_err)
  {
    FreeOMXInputBuffers(false);
    Deinitialize();
    return false;
  }

  m_is_open = true;
  m_drop_state = false;
  m_videoplayback_done = false;

  // crank it up.
  StartDecoder();

  return true;
}