1*77c1e3ccSAndroid Build Coastguard Worker /* 2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker * 4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker */ 11*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_COMMON_WEBMDEC_H_ 12*77c1e3ccSAndroid Build Coastguard Worker #define AOM_COMMON_WEBMDEC_H_ 13*77c1e3ccSAndroid Build Coastguard Worker 14*77c1e3ccSAndroid Build Coastguard Worker #include "common/tools_common.h" 15*77c1e3ccSAndroid Build Coastguard Worker 16*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 17*77c1e3ccSAndroid Build Coastguard Worker extern "C" { 18*77c1e3ccSAndroid Build Coastguard Worker #endif 19*77c1e3ccSAndroid Build Coastguard Worker 20*77c1e3ccSAndroid Build Coastguard Worker struct AvxInputContext; 21*77c1e3ccSAndroid Build Coastguard Worker 22*77c1e3ccSAndroid Build Coastguard Worker struct WebmInputContext { 23*77c1e3ccSAndroid Build Coastguard Worker void *reader; 24*77c1e3ccSAndroid Build Coastguard Worker void *segment; 25*77c1e3ccSAndroid Build Coastguard Worker uint8_t *buffer; 26*77c1e3ccSAndroid Build Coastguard Worker const void *cluster; 27*77c1e3ccSAndroid Build Coastguard Worker const void *block_entry; 28*77c1e3ccSAndroid Build Coastguard Worker const void *block; 29*77c1e3ccSAndroid Build Coastguard Worker int block_frame_index; 30*77c1e3ccSAndroid Build Coastguard Worker int video_track_index; 31*77c1e3ccSAndroid Build Coastguard Worker int64_t timestamp_ns; 32*77c1e3ccSAndroid Build Coastguard Worker int is_key_frame; 33*77c1e3ccSAndroid Build Coastguard Worker int reached_eos; 34*77c1e3ccSAndroid Build Coastguard Worker }; 35*77c1e3ccSAndroid Build Coastguard Worker 36*77c1e3ccSAndroid Build Coastguard Worker // Checks if the input is a WebM file. If so, initializes WebMInputContext so 37*77c1e3ccSAndroid Build Coastguard Worker // that webm_read_frame can be called to retrieve a video frame. 38*77c1e3ccSAndroid Build Coastguard Worker // Returns 1 on success and 0 on failure or input is not WebM file. 39*77c1e3ccSAndroid Build Coastguard Worker // TODO(vigneshv): Refactor this function into two smaller functions specific 40*77c1e3ccSAndroid Build Coastguard Worker // to their task. 41*77c1e3ccSAndroid Build Coastguard Worker int file_is_webm(struct WebmInputContext *webm_ctx, 42*77c1e3ccSAndroid Build Coastguard Worker struct AvxInputContext *aom_ctx); 43*77c1e3ccSAndroid Build Coastguard Worker 44*77c1e3ccSAndroid Build Coastguard Worker // Reads a WebM Video Frame. Memory for the buffer is created, owned and managed 45*77c1e3ccSAndroid Build Coastguard Worker // by this function. For the first call, |buffer| should be NULL and 46*77c1e3ccSAndroid Build Coastguard Worker // |*buffer_size| should be 0. Once all the frames are read and used, 47*77c1e3ccSAndroid Build Coastguard Worker // webm_free() should be called, otherwise there will be a leak. 48*77c1e3ccSAndroid Build Coastguard Worker // Parameters: 49*77c1e3ccSAndroid Build Coastguard Worker // webm_ctx - WebmInputContext object 50*77c1e3ccSAndroid Build Coastguard Worker // buffer - pointer where the frame data will be filled. 51*77c1e3ccSAndroid Build Coastguard Worker // bytes_read - pointer to bytes read. 52*77c1e3ccSAndroid Build Coastguard Worker // buffer_size - pointer to buffer size. 53*77c1e3ccSAndroid Build Coastguard Worker // Return values: 54*77c1e3ccSAndroid Build Coastguard Worker // 0 - Success 55*77c1e3ccSAndroid Build Coastguard Worker // 1 - End of Stream 56*77c1e3ccSAndroid Build Coastguard Worker // -1 - Error 57*77c1e3ccSAndroid Build Coastguard Worker int webm_read_frame(struct WebmInputContext *webm_ctx, uint8_t **buffer, 58*77c1e3ccSAndroid Build Coastguard Worker size_t *bytes_read, size_t *buffer_size); 59*77c1e3ccSAndroid Build Coastguard Worker 60*77c1e3ccSAndroid Build Coastguard Worker // Guesses the frame rate of the input file based on the container timestamps. 61*77c1e3ccSAndroid Build Coastguard Worker int webm_guess_framerate(struct WebmInputContext *webm_ctx, 62*77c1e3ccSAndroid Build Coastguard Worker struct AvxInputContext *aom_ctx); 63*77c1e3ccSAndroid Build Coastguard Worker 64*77c1e3ccSAndroid Build Coastguard Worker // Resets the WebMInputContext. 65*77c1e3ccSAndroid Build Coastguard Worker void webm_free(struct WebmInputContext *webm_ctx); 66*77c1e3ccSAndroid Build Coastguard Worker 67*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 68*77c1e3ccSAndroid Build Coastguard Worker } // extern "C" 69*77c1e3ccSAndroid Build Coastguard Worker #endif 70*77c1e3ccSAndroid Build Coastguard Worker 71*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_COMMON_WEBMDEC_H_ 72