void
MediaPictureResamplerTest::writePicture(const char* prefix, int32_t* frameNo,
    MediaPicture* picture,
    MediaPictureResampler* resampler,
    MediaPicture* resampled)
{
  char filename[2048];

  // resample the image from YUV to RGBA
  resampler->resample(resampled, picture);

  // write data as PGM file.
  snprintf(filename, sizeof(filename), "%s-%06d.png", prefix, *frameNo);
  // only write every n'th frame to save disk space
  RefPointer<Buffer> buf = resampled->getData(0);
  uint8_t* data = (uint8_t*)buf->getBytes(0, buf->getBufferSize());
  if (!((*frameNo) % 30)) {
    lodepng_encode32_file(filename, data, resampled->getWidth(), resampled->getHeight());
  }
  (*frameNo)++;

  // check the frame metadata
  RefPointer<KeyValueBag> md = picture->getMetaData();
  if (md) {
    int n =  md->getNumKeys();
    for(int i = 0; i < n; i++) {
      const char* key = md->getKey(i);
      const char* val = md->getValue(key, KeyValueBag::KVB_NONE);
      fprintf(stderr, "%s : %s", key, val);
    }
  }

}
示例#2
0
void
MetaDataTest :: testContainerGetMetaData()
{
  Helper h;
  h.setupReading("testfile.mp3");
  RefPointer<IMetaData> meta = h.container->getMetaData();
  VS_TUT_ENSURE("got meta data", meta);
  if (meta) {
    int32_t numKeys = meta->getNumKeys();
    VS_TUT_ENSURE("should be right", numKeys >= 5);
    VS_TUT_ENSURE("should be right", numKeys <= 7);
    for(int32_t i = 0; i < numKeys; i++)
    {
      const char* key = meta->getKey(i);
      VS_TUT_ENSURE("should be found", key);
      VS_TUT_ENSURE("should be found", *key);
      const char* value = meta->getValue(key, IMetaData::METADATA_NONE);
      VS_TUT_ENSURE("should be found", value);
      VS_TUT_ENSURE("should be found", *value);
    }
  }
}
示例#3
0
void
MetaDataTest :: testFLVContainerGetMetaData()
{
  Helper h;
  return;
  h.setupReading("testfile.flv");
  RefPointer<IMetaData> meta = h.container->getMetaData();
  VS_TUT_ENSURE("got meta data", meta);
  if (meta) {
    int32_t numKeys = meta->getNumKeys();
    if (numKeys > 0) { // using FFmpeg with a patch for FLV meta-data reading
      VS_TUT_ENSURE_EQUALS("should be right", numKeys, 11);
      for(int32_t i = 0; i < numKeys; i++)
      {
        const char* key = meta->getKey(i);
        VS_TUT_ENSURE("should be found", key);
        VS_TUT_ENSURE("should be found", *key);
        const char* value = meta->getValue(key, IMetaData::METADATA_NONE);
        VS_TUT_ENSURE("should be found", value);
        VS_TUT_ENSURE("should be found", *value);
      }
    }
  }
}