chromium/third_party/libavif/src/apps/shared/y4m.c

// Copyright 2019 Joe Drago. All rights reserved.
// SPDX-License-Identifier: BSD-2-Clause

// This is a barebones y4m reader/writer for basic libavif testing. It is NOT comprehensive!

#include "y4m.h"

#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "avif/avif.h"
#include "avifutil.h"

#define Y4M_MAX_LINE_SIZE

struct y4mFrameIterator
{};

// Sets frame->format, frame->depth, frame->hasAlpha, and frame->chromaSamplePosition.
static avifBool y4mColorSpaceParse(const char * formatString, struct y4mFrameIterator * frame)
{}

// Returns an unsigned integer value parsed from [start:end[.
// Returns -1 in case of failure.
static int y4mReadUnsignedInt(const char * start, const char * end)
{}

// Note: this modifies framerateString
static avifBool y4mFramerateParse(char * framerateString, avifAppSourceTiming * sourceTiming)
{}

static avifBool getHeaderString(uint8_t * p, uint8_t * end, char * out, size_t maxChars)
{}

static int y4mReadLine(FILE * inputFile, avifRWData * raw, const char * displayFilename)
{}

// Limits each sample value to fit into avif->depth bits.
// Returns AVIF_TRUE if any sample was clamped this way.
static avifBool y4mClampSamples(avifImage * avif)
{}

#define ADVANCE(BYTES)

avifBool y4mRead(const char * inputFilename,
                 uint32_t imageSizeLimit,
                 avifImage * avif,
                 avifAppSourceTiming * sourceTiming,
                 struct y4mFrameIterator ** iter)
{}

avifBool y4mWrite(const char * outputFilename, const avifImage * avif)
{}