Ejemplo n.º 1
0
// ######################################################################
GenericFrame::GenericFrame(const VideoFrame& vidframe)
  :
  itsNativeType(vidframe.getDims().isNonEmpty()
                ? GenericFrame::VIDEO
                : GenericFrame::NONE),
  itsVideo(vidframe)
{}
Ejemplo n.º 2
0
void FfmpegEncoder::writeVideoFrame(const VideoFrame& frame)
{
GVX_TRACE(__PRETTY_FUNCTION__);

  if (frame.getDims().w() != itsContext.width ||
      frame.getDims().h() != itsContext.height)
    {
      LFATAL("wrong size mpeg output frame "
             "(expected %dx%d, got %dx%d)",
             itsContext.width, itsContext.height,
             frame.getDims().w(), frame.getDims().h());
    }

  AVFrame picture;
#if defined(INVT_FFMPEG_HAS_DEFAULTS_FUNCTIONS)
  avcodec_get_frame_defaults(&picture);
#else
  {
    AVFrame* tmp = avcodec_alloc_frame();
    memcpy(&picture, tmp, sizeof(AVFrame));
    free(tmp);
  }
#endif

  if (convertVideoFrameToAVFrame(frame,
                                 itsContext.pix_fmt,
                                 &picture))
    {
      this->writeRawFrame(&picture);
    }
  else
    {
      // OK, we couldn't do a direct conversion from
      // VideoFrame->AVFrame (probably the pixel formats didn't
      // match), so let's just fall back to RGB instead:
      this->writeRGB(frame.toRgb());
    }
}