示例#1
0
void MovieDecoder::initialize(const std::string& filename)
{
    av_register_all();
    avcodec_register_all();

    std::string inputFile = filename == "-" ? "pipe:" : filename;

    allowSeek_ = filename.find("rtsp://") != 0;

	if (avformat_open_input(&pFormatContext_, inputFile.c_str(), 0, 0) != 0)
	{
		destroy();
		throw std::logic_error(std::string("Could not open input file: ") + filename);
	}

    // This code helps to generate thumbnail for the .avi video files.
    // It successfully generated them on the simulator but crashed on the device.
//	if (avformat_find_stream_info(pFormatContext_, 0) < 0)
//    {
//		destroy();
//        throw std::logic_error(std::string("Could not find stream information"));
//    }

    initializeVideo();
    pFrame_ = avcodec_alloc_frame();
    if(pFrame_ == 0)
    {
    	fprintf(stderr, "sdfsdf \n");
    }
    else
    {
    	//fprintf(stderr, "trtrtrtrtrtrt   %p pointer value\n",pFrame_);
    }
}
void MovieDecoder::initialize(const QString& filename)
{
    av_register_all();
    avcodec_register_all();

    QFileInfo fileInfo(filename);

    
    
    if ((!m_FormatContextWasGiven) && avformat_open_input(&m_pFormatContext, fileInfo.absoluteFilePath().toLocal8Bit().data(), NULL, NULL) != 0) {
        qDebug() <<  "Could not open input file: " << fileInfo.absoluteFilePath();
        return;
    }

    if (avformat_find_stream_info(m_pFormatContext, 0) < 0) {
        qDebug() << "Could not find stream information";
        return;
    }

    initializeVideo();
    m_pFrame = av_frame_alloc();

    if (m_pFrame) {
        m_initialized=true;
    }
}
示例#3
0
void MovieDecoder::initialize(const string& filename)
{
    //av_register_all();
    //avcodec_register_all();
    //avformat_network_init();

    string inputFile = filename == "-" ? "pipe:" : filename;
    m_AllowSeek = (filename != "-") && (filename.find("rtsp://") != 0) && (filename.find("udp://") != 0);
    

    if ((!m_FormatContextWasGiven) && avformat_open_input(&m_pFormatContext, inputFile.c_str(), nullptr, nullptr) != 0)
    {
        destroy();
        throw logic_error(string("Could not open input file: ") + filename);
    }

	if (avformat_find_stream_info(m_pFormatContext, nullptr) < 0)
    {
        destroy();
        throw logic_error(string("Could not find stream information"));
    }


    initializeVideo();
	
    m_pFrame = av_frame_alloc();


	widthVideo = m_pVideoCodecContext->width;
	heightVideo = m_pVideoCodecContext->height;
}
示例#4
0
void MovieDecoder::initialize(const string& filename)
{
    av_register_all();
    avcodec_register_all();
    avformat_network_init();

    string inputFile = filename == "-" ? "pipe:" : filename;
    m_AllowSeek = (filename != "-") && (filename.find("rtsp://") != 0) && (filename.find("udp://") != 0);
    int open_input_result = 0;
    {
      auto lock = ThreadPool::lock("ffmpeg_avcodec_open");
      open_input_result = avformat_open_input(&m_pFormatContext, inputFile.c_str(), nullptr, nullptr);
    }
    
    if ((!m_FormatContextWasGiven) && open_input_result != 0)
    {
        destroy();
        throw logic_error(string("Could not open input file: ") + filename);
    }

    if (avformat_find_stream_info(m_pFormatContext, nullptr) < 0)
    {
        destroy();
        throw logic_error(string("Could not find stream information"));
    }

    initializeVideo();
    m_pFrame = av_frame_alloc();
}
int VideoDecoder::init(const string& filename)
{
	av_register_all();
    avcodec_register_all();
    avformat_network_init();
    avfilter_register_all();

    if (avformat_open_input(&mFmtCtxPtr, filename.c_str(), nullptr, nullptr) != 0) {
    	LOGE("Could not open input file: %s", filename.c_str());
    	goto failed;
    }

    if (avformat_find_stream_info(mFmtCtxPtr, nullptr) < 0) {
        LOGE("Could not find stream information");
        goto failed;
    }

    if (initializeVideo() < 0) {
    	LOGE("Init video failed");
    	goto failed;
    }

    mFramePtr = av_frame_alloc();
    if (!mFramePtr) {
    	LOGE("Not enough memory");
    	goto failed;
    }

    mFilterFramePtr = av_frame_alloc();
    if (!mFilterFramePtr) {
    	LOGE("Not enough memory");
    	goto failed;
    }

    return 0;
failed:
	destroy();
	return -1;
}
int main(int argc, char *argv[])
{
	if (!initializeLdraw())
		return -1;
	if (!initializeVideo(argc, argv))
		return -1;
	
	if (argc < 2) {
		std::cerr << "Usage: " << argv[0] << " [filename] (-immediate | -varray | -vbo)" << std::endl;
		return -2;
	} else if (argc > 2) {
		if (std::strcmp(argv[2], "-immediate") == 0)
			mode_ = ldraw_renderer::renderer_opengl_factory::mode_immediate;
		else if (std::strcmp(argv[2], "-varray") == 0)
			mode_ = ldraw_renderer::renderer_opengl_factory::mode_varray;
		else if (std::strcmp(argv[2], "-vbo") == 0)
			mode_ = ldraw_renderer::renderer_opengl_factory::mode_vbo;
		else {
			std::cerr << "invalid option." << std::endl;
			return -3;
		}
	}

	initDisplay();
	
	if (!initializeModel(argv[1]))
		return -1;

	resize(SCREEN_WIDTH, SCREEN_HEIGHT);	
	
	glutDisplayFunc(displayFunc);
	glutIdleFunc(displayFunc);
	glutReshapeFunc(resize);
	glutMainLoop();

	return 0;
}
示例#7
0
AppInitializer::AppInitializer() {
	initializeVideo();
}