This source file includes following definitions.
- set_input_file
- get_image
- skip_frames
#include "image-io-png.h"
#include <assert.h>
#if HAVE_VIDEOGFX
#include <libvideogfx.hh>
using namespace videogfx;
ImageSource_PNG::ImageSource_PNG()
{
mFilenameTemplate = NULL;
mNextImageNumber = 1;
mReachedEndOfStream = false;
mWidth=mHeight=0;
}
ImageSource_PNG::~ImageSource_PNG()
{
}
bool ImageSource_PNG::set_input_file(const char* filename)
{
mFilenameTemplate = filename;
return true;
}
de265_image* ImageSource_PNG::get_image(bool block)
{
if (mReachedEndOfStream) return NULL;
char filename[1000];
sprintf(filename,mFilenameTemplate,mNextImageNumber);
mNextImageNumber++;
Image<Pixel> input;
bool success = videogfx::ReadImage_PNG(input, filename);
if (!success) {
mReachedEndOfStream = true;
return NULL;
}
mWidth = input.AskWidth();
mHeight= input.AskHeight();
de265_image* img = new de265_image;
img->alloc_image(mWidth,mHeight,de265_chroma_444, NULL, false,
NULL, NULL, 0, NULL, false);
assert(img);
uint8_t* p;
int stride;
for (int c=0;c<3;c++) {
int h265channel;
switch (c) {
case 0: h265channel=2; break;
case 1: h265channel=0; break;
case 2: h265channel=1; break;
}
p = img->get_image_plane(h265channel);
stride = img->get_image_stride(h265channel);
for (int y=0;y<mHeight;y++) {
memcpy(p, input.AskFrame((BitmapChannel(c)))[y], mWidth);
p += stride;
}
}
return img;
}
void ImageSource_PNG::skip_frames(int n)
{
mNextImageNumber += n;
}
#endif