2013-11-19 02:39:51 +04:00
|
|
|
/*
|
2016-03-24 22:08:51 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2013-11-19 02:39:51 +04:00
|
|
|
*
|
2016-03-24 22:08:51 +03:00
|
|
|
* This source code is subject to the terms of the BSD 2 Clause License and
|
|
|
|
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
|
|
|
* was not distributed with this source code in the LICENSE file, you can
|
|
|
|
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
|
|
|
* Media Patent License 1.0 was not distributed with this source code in the
|
|
|
|
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
2013-11-19 02:39:51 +04:00
|
|
|
*/
|
|
|
|
#ifndef WEBMDEC_H_
|
|
|
|
#define WEBMDEC_H_
|
|
|
|
|
|
|
|
#include "./tools_common.h"
|
|
|
|
|
2014-01-19 00:16:11 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-11-19 02:39:51 +04:00
|
|
|
struct VpxInputContext;
|
|
|
|
|
|
|
|
struct WebmInputContext {
|
2014-04-03 11:41:14 +04:00
|
|
|
void *reader;
|
|
|
|
void *segment;
|
|
|
|
uint8_t *buffer;
|
|
|
|
const void *cluster;
|
|
|
|
const void *block_entry;
|
|
|
|
const void *block;
|
|
|
|
int block_frame_index;
|
|
|
|
int video_track_index;
|
|
|
|
uint64_t timestamp_ns;
|
2015-01-27 23:26:28 +03:00
|
|
|
int is_key_frame;
|
2015-03-30 22:58:26 +03:00
|
|
|
int reached_eos;
|
2013-11-19 02:39:51 +04:00
|
|
|
};
|
|
|
|
|
2014-04-03 11:41:14 +04:00
|
|
|
// Checks if the input is a WebM file. If so, initializes WebMInputContext so
|
|
|
|
// that webm_read_frame can be called to retrieve a video frame.
|
|
|
|
// Returns 1 on success and 0 on failure or input is not WebM file.
|
|
|
|
// TODO(vigneshv): Refactor this function into two smaller functions specific
|
|
|
|
// to their task.
|
2013-11-19 02:39:51 +04:00
|
|
|
int file_is_webm(struct WebmInputContext *webm_ctx,
|
2016-03-25 22:11:05 +03:00
|
|
|
struct VpxInputContext *aom_ctx);
|
2013-11-19 02:39:51 +04:00
|
|
|
|
2014-04-03 11:41:14 +04:00
|
|
|
// Reads a WebM Video Frame. Memory for the buffer is created, owned and managed
|
|
|
|
// by this function. For the first call, |buffer| should be NULL and
|
|
|
|
// |*bytes_in_buffer| should be 0. Once all the frames are read and used,
|
|
|
|
// webm_free() should be called, otherwise there will be a leak.
|
|
|
|
// Parameters:
|
|
|
|
// webm_ctx - WebmInputContext object
|
|
|
|
// buffer - pointer where the frame data will be filled.
|
|
|
|
// bytes_in_buffer - pointer to buffer size.
|
|
|
|
// buffer_size - unused TODO(vigneshv): remove this
|
|
|
|
// Return values:
|
|
|
|
// 0 - Success
|
|
|
|
// 1 - End of Stream
|
|
|
|
// -1 - Error
|
|
|
|
// TODO(vigneshv): Make the return values consistent across all functions in
|
|
|
|
// this file.
|
2016-01-27 23:42:45 +03:00
|
|
|
int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer,
|
|
|
|
size_t *bytes_in_buffer, size_t *buffer_size);
|
2013-11-19 02:39:51 +04:00
|
|
|
|
2014-04-03 11:41:14 +04:00
|
|
|
// Guesses the frame rate of the input file based on the container timestamps.
|
2013-11-19 02:39:51 +04:00
|
|
|
int webm_guess_framerate(struct WebmInputContext *webm_ctx,
|
2016-03-25 22:11:05 +03:00
|
|
|
struct VpxInputContext *aom_ctx);
|
2013-11-19 02:39:51 +04:00
|
|
|
|
2014-04-03 11:41:14 +04:00
|
|
|
// Resets the WebMInputContext.
|
2013-11-19 02:39:51 +04:00
|
|
|
void webm_free(struct WebmInputContext *webm_ctx);
|
|
|
|
|
2014-01-19 00:16:11 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2013-11-19 02:39:51 +04:00
|
|
|
#endif // WEBMDEC_H_
|