Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1.         void Movie::init(const io::path &path) {
  2.  
  3.             // TODO: error checking
  4.  
  5.             avcodec_register_all();
  6.             av_log_set_level(AV_LOG_DEBUG);
  7.  
  8.             auto file = new FileInputStream(path.filename());
  9.             if (file->open(path.c_str())) {
  10.        
  11.                 info() << "Opened video file";
  12.  
  13.                 // INBUFF_SIZE = 4096
  14.                 uint8_t inputBuffer[4096 + FF_INPUT_BUFFER_PADDING_SIZE];
  15.                 char buffer[1024];
  16.  
  17.                 AVPacket avPacket;
  18.                 av_init_packet(&avPacket);
  19.  
  20.                 info() << "Video decoding.";
  21.  
  22.                 mCodec = avcodec_find_decoder(CODEC_ID_BINKVIDEO);
  23.                 if (mCodec == nullptr) {
  24.  
  25.                     info() << "Failed to find a codec.";
  26.  
  27.                     return;
  28.                 }
  29.  
  30.                 info() << "Loaded codec";
  31.  
  32.                 mCodecContext = avcodec_alloc_context3(mCodec);
  33.                 if (mCodecContext == nullptr) {
  34.  
  35.                     info() << "Failed to create a codec context.";
  36.  
  37.                     return;
  38.                 }
  39.  
  40.                 info() << "Created a codec context";
  41.  
  42.                 mFrame = av_frame_alloc();
  43.                 if (avcodec_open2(mCodecContext, mCodec, nullptr) < 0) {
  44.  
  45.                     info() << "Fail";
  46.                 }
  47.             }
  48.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement