1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * AVC helper functions for muxers 3cabdff1aSopenharmony_ci * Copyright (c) 2008 Aurelien Jacobs <aurel@gnuage.org> 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci#ifndef AVFORMAT_AVC_H 23cabdff1aSopenharmony_ci#define AVFORMAT_AVC_H 24cabdff1aSopenharmony_ci 25cabdff1aSopenharmony_ci#include <stdint.h> 26cabdff1aSopenharmony_ci#include "libavutil/rational.h" 27cabdff1aSopenharmony_ci#include "avio.h" 28cabdff1aSopenharmony_ci 29cabdff1aSopenharmony_citypedef struct NALU { 30cabdff1aSopenharmony_ci int offset; 31cabdff1aSopenharmony_ci uint32_t size; 32cabdff1aSopenharmony_ci} NALU; 33cabdff1aSopenharmony_ci 34cabdff1aSopenharmony_citypedef struct NALUList { 35cabdff1aSopenharmony_ci NALU *nalus; 36cabdff1aSopenharmony_ci unsigned nalus_array_size; 37cabdff1aSopenharmony_ci unsigned nb_nalus; ///< valid entries in nalus 38cabdff1aSopenharmony_ci} NALUList; 39cabdff1aSopenharmony_ci 40cabdff1aSopenharmony_ci/* This function will parse the given annex B buffer and create 41cabdff1aSopenharmony_ci * a NALUList from it. This list can be passed to ff_nal_units_write_list() 42cabdff1aSopenharmony_ci * to write the access unit reformatted to mp4. 43cabdff1aSopenharmony_ci * 44cabdff1aSopenharmony_ci * @param list A NALUList. The list->nalus and list->nalus_array_size 45cabdff1aSopenharmony_ci * must be valid when calling this function and may be updated. 46cabdff1aSopenharmony_ci * nb_nalus is set by this function on success. 47cabdff1aSopenharmony_ci * @param buf buffer containing annex B H.264 or H.265. Must be padded. 48cabdff1aSopenharmony_ci * @param size size of buf, excluding padding. 49cabdff1aSopenharmony_ci * @return < 0 on error, the size of the mp4-style packet on success. 50cabdff1aSopenharmony_ci */ 51cabdff1aSopenharmony_ciint ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size); 52cabdff1aSopenharmony_ci 53cabdff1aSopenharmony_ci/* Writes a NALUList to the specified AVIOContext. The list must originate 54cabdff1aSopenharmony_ci * from ff_nal_units_create_list() with the same buf. */ 55cabdff1aSopenharmony_civoid ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, 56cabdff1aSopenharmony_ci const uint8_t *buf); 57cabdff1aSopenharmony_ci 58cabdff1aSopenharmony_ciint ff_avc_parse_nal_units(AVIOContext *s, const uint8_t *buf, int size); 59cabdff1aSopenharmony_ciint ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size); 60cabdff1aSopenharmony_ciint ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len); 61cabdff1aSopenharmony_ciconst uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end); 62cabdff1aSopenharmony_ciint ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size); 63cabdff1aSopenharmony_ciconst uint8_t *ff_avc_mp4_find_startcode(const uint8_t *start, 64cabdff1aSopenharmony_ci const uint8_t *end, 65cabdff1aSopenharmony_ci int nal_length_size); 66cabdff1aSopenharmony_ciuint8_t *ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, 67cabdff1aSopenharmony_ci uint32_t *dst_len, int header_len); 68cabdff1aSopenharmony_ci 69cabdff1aSopenharmony_citypedef struct { 70cabdff1aSopenharmony_ci uint8_t id; 71cabdff1aSopenharmony_ci uint8_t profile_idc; 72cabdff1aSopenharmony_ci uint8_t level_idc; 73cabdff1aSopenharmony_ci uint8_t constraint_set_flags; 74cabdff1aSopenharmony_ci uint8_t chroma_format_idc; 75cabdff1aSopenharmony_ci uint8_t bit_depth_luma; 76cabdff1aSopenharmony_ci uint8_t bit_depth_chroma; 77cabdff1aSopenharmony_ci uint8_t frame_mbs_only_flag; 78cabdff1aSopenharmony_ci AVRational sar; 79cabdff1aSopenharmony_ci} H264SPS; 80cabdff1aSopenharmony_ci 81cabdff1aSopenharmony_ciint ff_avc_decode_sps(H264SPS *sps, const uint8_t *buf, int buf_size); 82cabdff1aSopenharmony_ci 83cabdff1aSopenharmony_ci#endif /* AVFORMAT_AVC_H */ 84