/* * H.265 video codec. * Copyright (c) 2013-2014 struktur AG, Dirk Farin * * Authors: struktur AG, Dirk Farin * * This file is part of libde265. * * libde265 is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * libde265 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with libde265. If not, see . */ #include "libde265/image-io.h" #include ImageSource::ImageSource() { } ImageSource_YUV::ImageSource_YUV() : mFH(NULL) { } ImageSource_YUV::~ImageSource_YUV() { if (mFH) { fclose(mFH); } } bool ImageSource_YUV::set_input_file(const char* filename, int w,int h) { assert(mFH==NULL); mFH = fopen(filename,"rb"); if (mFH==NULL) { return false; } width =w; height=h; mReachedEndOfFile = false; return true; } de265_image* ImageSource_YUV::read_next_image() { if (mReachedEndOfFile) return NULL; de265_image* img = new de265_image; img->alloc_image(width,height,de265_chroma_420, NULL, false, NULL, /*NULL,*/ 0, NULL, false); assert(img); // TODO: error handling // --- load image --- uint8_t* p; int stride; p = img->get_image_plane(0); stride = img->get_image_stride(0); for (int y=0;yget_image_plane(1); stride = img->get_image_stride(1); for (int y=0;yget_image_plane(2); stride = img->get_image_stride(2); for (int y=0;yget_width(); int height= img->get_height(); p = img->get_image_plane(0); stride = img->get_image_stride(0); for (int y=0;yget_image_plane(1); stride = img->get_image_stride(1); for (int y=0;yget_image_plane(2); stride = img->get_image_stride(2); for (int y=0;y