You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chromium/chromium-131-el8-libavcodec...

526 lines
18 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

--- /dev/null 2024-11-22 07:51:33.845958571 +0100
+++ chromium-131.0.6778.85/third_party/ffmpeg/libavcodec/parser.h 2024-11-19 23:48:49.634320300 +0100
@@ -0,0 +1,58 @@
+/*
+ * AVCodecParser prototypes and definitions
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_PARSER_H
+#define AVCODEC_PARSER_H
+
+#include "avcodec.h"
+
+typedef struct ParseContext{
+ uint8_t *buffer;
+ int index;
+ int last_index;
+ unsigned int buffer_size;
+ uint32_t state; ///< contains the last few bytes in MSB order
+ int frame_start_found;
+ int overread; ///< the number of bytes which where irreversibly read from the next frame
+ int overread_index; ///< the index into ParseContext.buffer of the overread bytes
+ uint64_t state64; ///< contains the last 8 bytes in MSB order
+} ParseContext;
+
+#define END_NOT_FOUND (-100)
+
+/**
+ * Combine the (truncated) bitstream to a complete frame.
+ * @return -1 if no complete frame could be created,
+ * AVERROR(ENOMEM) if there was a memory allocation error
+ */
+int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size);
+void ff_parse_close(AVCodecParserContext *s);
+
+/**
+ * Fetch timestamps for a specific byte within the current access unit.
+ * @param off byte position within the access unit
+ * @param remove Found timestamps will be removed if set to 1, kept if set to 0.
+ * @param fuzzy Only use found value if it is more informative than what we already have
+ */
+void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy);
+
+#endif /* AVCODEC_PARSER_H */
--- /dev/null 2024-11-22 07:51:33.845958571 +0100
+++ chromium-131.0.6778.85/third_party/ffmpeg/libavcodec/parser.c 2024-11-19 23:48:49.633320000 +0100
@@ -0,0 +1,295 @@
+/*
+ * Audio and Video frame extraction
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <inttypes.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
+
+#include "parser.h"
+
+AVCodecParserContext *av_parser_init(int codec_id)
+{
+ AVCodecParserContext *s = NULL;
+ const AVCodecParser *parser;
+ void *i = 0;
+ int ret;
+
+ if (codec_id == AV_CODEC_ID_NONE)
+ return NULL;
+
+ while ((parser = av_parser_iterate(&i))) {
+ if (parser->codec_ids[0] == codec_id ||
+ parser->codec_ids[1] == codec_id ||
+ parser->codec_ids[2] == codec_id ||
+ parser->codec_ids[3] == codec_id ||
+ parser->codec_ids[4] == codec_id ||
+ parser->codec_ids[5] == codec_id ||
+ parser->codec_ids[6] == codec_id)
+ goto found;
+ }
+ return NULL;
+
+found:
+ s = av_mallocz(sizeof(AVCodecParserContext));
+ if (!s)
+ goto err_out;
+ s->parser = parser;
+ s->priv_data = av_mallocz(parser->priv_data_size);
+ if (!s->priv_data)
+ goto err_out;
+ s->fetch_timestamp=1;
+ s->pict_type = AV_PICTURE_TYPE_I;
+ if (parser->parser_init) {
+ ret = parser->parser_init(s);
+ if (ret != 0)
+ goto err_out;
+ }
+ s->key_frame = -1;
+ s->dts_sync_point = INT_MIN;
+ s->dts_ref_dts_delta = INT_MIN;
+ s->pts_dts_delta = INT_MIN;
+ s->format = -1;
+
+ return s;
+
+err_out:
+ if (s)
+ av_freep(&s->priv_data);
+ av_free(s);
+ return NULL;
+}
+
+void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy)
+{
+ int i;
+
+ if (!fuzzy) {
+ s->dts =
+ s->pts = AV_NOPTS_VALUE;
+ s->pos = -1;
+ s->offset = 0;
+ }
+ for (i = 0; i < AV_PARSER_PTS_NB; i++) {
+ if (s->cur_offset + off >= s->cur_frame_offset[i] &&
+ (s->frame_offset < s->cur_frame_offset[i] ||
+ (!s->frame_offset && !s->next_frame_offset)) && // first field/frame
+ // check disabled since MPEG-TS does not send complete PES packets
+ /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){
+
+ if (!fuzzy || s->cur_frame_dts[i] != AV_NOPTS_VALUE) {
+ s->dts = s->cur_frame_dts[i];
+ s->pts = s->cur_frame_pts[i];
+ s->pos = s->cur_frame_pos[i];
+ s->offset = s->next_frame_offset - s->cur_frame_offset[i];
+ }
+ if (remove)
+ s->cur_frame_offset[i] = INT64_MAX;
+ if (s->cur_offset + off < s->cur_frame_end[i])
+ break;
+ }
+ }
+}
+
+int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
+ uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size,
+ int64_t pts, int64_t dts, int64_t pos)
+{
+ int index, i;
+ uint8_t dummy_buf[AV_INPUT_BUFFER_PADDING_SIZE];
+
+ av_assert1(avctx->codec_id != AV_CODEC_ID_NONE);
+
+ /* Parsers only work for the specified codec ids. */
+ av_assert1(avctx->codec_id == s->parser->codec_ids[0] ||
+ avctx->codec_id == s->parser->codec_ids[1] ||
+ avctx->codec_id == s->parser->codec_ids[2] ||
+ avctx->codec_id == s->parser->codec_ids[3] ||
+ avctx->codec_id == s->parser->codec_ids[4] ||
+ avctx->codec_id == s->parser->codec_ids[5] ||
+ avctx->codec_id == s->parser->codec_ids[6]);
+
+ if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
+ s->next_frame_offset =
+ s->cur_offset = pos;
+ s->flags |= PARSER_FLAG_FETCHED_OFFSET;
+ }
+
+ if (buf_size == 0) {
+ /* padding is always necessary even if EOF, so we add it here */
+ memset(dummy_buf, 0, sizeof(dummy_buf));
+ buf = dummy_buf;
+ } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
+ /* add a new packet descriptor */
+ i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
+ s->cur_frame_start_index = i;
+ s->cur_frame_offset[i] = s->cur_offset;
+ s->cur_frame_end[i] = s->cur_offset + buf_size;
+ s->cur_frame_pts[i] = pts;
+ s->cur_frame_dts[i] = dts;
+ s->cur_frame_pos[i] = pos;
+ }
+
+ if (s->fetch_timestamp) {
+ s->fetch_timestamp = 0;
+ s->last_pts = s->pts;
+ s->last_dts = s->dts;
+ s->last_pos = s->pos;
+ ff_fetch_timestamp(s, 0, 0, 0);
+ }
+ /* WARNING: the returned index can be negative */
+ index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
+ poutbuf_size, buf, buf_size);
+ av_assert0(index > -0x20000000); // The API does not allow returning AVERROR codes
+#define FILL(name) if(s->name > 0 && avctx->name <= 0) avctx->name = s->name
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ FILL(field_order);
+ FILL(coded_width);
+ FILL(coded_height);
+ FILL(width);
+ FILL(height);
+ }
+
+ /* update the file pointer */
+ if (*poutbuf_size) {
+ /* fill the data for the current frame */
+ s->frame_offset = s->next_frame_offset;
+
+ /* offset of the next frame */
+ s->next_frame_offset = s->cur_offset + index;
+ s->fetch_timestamp = 1;
+ } else {
+ /* Don't return a pointer to dummy_buf. */
+ *poutbuf = NULL;
+ }
+ if (index < 0)
+ index = 0;
+ s->cur_offset += index;
+ return index;
+}
+
+void av_parser_close(AVCodecParserContext *s)
+{
+ if (s) {
+ if (s->parser->parser_close)
+ s->parser->parser_close(s);
+ av_freep(&s->priv_data);
+ av_free(s);
+ }
+}
+
+int ff_combine_frame(ParseContext *pc, int next,
+ const uint8_t **buf, int *buf_size)
+{
+ if (pc->overread) {
+ ff_dlog(NULL, "overread %d, state:%"PRIX32" next:%d index:%d o_index:%d\n",
+ pc->overread, pc->state, next, pc->index, pc->overread_index);
+ ff_dlog(NULL, "%X %X %X %X\n",
+ (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
+ }
+
+ /* Copy overread bytes from last frame into buffer. */
+ for (; pc->overread > 0; pc->overread--)
+ pc->buffer[pc->index++] = pc->buffer[pc->overread_index++];
+
+ if (next > *buf_size)
+ return AVERROR(EINVAL);
+
+ /* flush remaining if EOF */
+ if (!*buf_size && next == END_NOT_FOUND)
+ next = 0;
+
+ pc->last_index = pc->index;
+
+ /* copy into buffer end return */
+ if (next == END_NOT_FOUND) {
+ void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+ *buf_size + pc->index +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+
+ if (!new_buffer) {
+ av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", *buf_size + pc->index + AV_INPUT_BUFFER_PADDING_SIZE);
+ pc->index = 0;
+ return AVERROR(ENOMEM);
+ }
+ pc->buffer = new_buffer;
+ memcpy(&pc->buffer[pc->index], *buf, *buf_size);
+ memset(&pc->buffer[pc->index + *buf_size], 0, AV_INPUT_BUFFER_PADDING_SIZE);
+ pc->index += *buf_size;
+ return -1;
+ }
+
+ av_assert0(next >= 0 || pc->buffer);
+
+ *buf_size =
+ pc->overread_index = pc->index + next;
+
+ /* append to buffer */
+ if (pc->index) {
+ void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+ next + pc->index +
+ AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!new_buffer) {
+ av_log(NULL, AV_LOG_ERROR, "Failed to reallocate parser buffer to %d\n", next + pc->index + AV_INPUT_BUFFER_PADDING_SIZE);
+ *buf_size =
+ pc->overread_index =
+ pc->index = 0;
+ return AVERROR(ENOMEM);
+ }
+ pc->buffer = new_buffer;
+ if (next > -AV_INPUT_BUFFER_PADDING_SIZE)
+ memcpy(&pc->buffer[pc->index], *buf,
+ next + AV_INPUT_BUFFER_PADDING_SIZE);
+ pc->index = 0;
+ *buf = pc->buffer;
+ }
+
+ if (next < -8) {
+ pc->overread += -8 - next;
+ next = -8;
+ }
+ /* store overread bytes */
+ for (; next < 0; next++) {
+ pc->state = pc->state << 8 | pc->buffer[pc->last_index + next];
+ pc->state64 = pc->state64 << 8 | pc->buffer[pc->last_index + next];
+ pc->overread++;
+ }
+
+ if (pc->overread) {
+ ff_dlog(NULL, "overread %d, state:%"PRIX32" next:%d index:%d o_index:%d\n",
+ pc->overread, pc->state, next, pc->index, pc->overread_index);
+ ff_dlog(NULL, "%X %X %X %X\n",
+ (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
+ }
+
+ return 0;
+}
+
+void ff_parse_close(AVCodecParserContext *s)
+{
+ ParseContext *pc = s->priv_data;
+
+ av_freep(&pc->buffer);
+}
--- /dev/null 2024-11-22 07:51:33.845958571 +0100
+++ chromium-131.0.6778.85/third_party/ffmpeg/libavcodec/hevc/hevc.h 2024-11-19 23:48:49.494310400 +0100
@@ -0,0 +1,163 @@
+/*
+ * HEVC shared code
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HEVC_HEVC_H
+#define AVCODEC_HEVC_HEVC_H
+
+/**
+ * Table 7-1 NAL unit type codes and NAL unit type classes in
+ * T-REC-H.265-201802
+ */
+enum HEVCNALUnitType {
+ HEVC_NAL_TRAIL_N = 0,
+ HEVC_NAL_TRAIL_R = 1,
+ HEVC_NAL_TSA_N = 2,
+ HEVC_NAL_TSA_R = 3,
+ HEVC_NAL_STSA_N = 4,
+ HEVC_NAL_STSA_R = 5,
+ HEVC_NAL_RADL_N = 6,
+ HEVC_NAL_RADL_R = 7,
+ HEVC_NAL_RASL_N = 8,
+ HEVC_NAL_RASL_R = 9,
+ HEVC_NAL_VCL_N10 = 10,
+ HEVC_NAL_VCL_R11 = 11,
+ HEVC_NAL_VCL_N12 = 12,
+ HEVC_NAL_VCL_R13 = 13,
+ HEVC_NAL_VCL_N14 = 14,
+ HEVC_NAL_VCL_R15 = 15,
+ HEVC_NAL_BLA_W_LP = 16,
+ HEVC_NAL_BLA_W_RADL = 17,
+ HEVC_NAL_BLA_N_LP = 18,
+ HEVC_NAL_IDR_W_RADL = 19,
+ HEVC_NAL_IDR_N_LP = 20,
+ HEVC_NAL_CRA_NUT = 21,
+ HEVC_NAL_RSV_IRAP_VCL22 = 22,
+ HEVC_NAL_RS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E_P = 1,
+ HEVC_SLICE_I = 2,
+};
+
+enum {
+ // 7.4.3.1: vps_max_layers_minus1 is in [0, 62].
+ HEVC_MAX_LAYERS = 63,
+ // 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6].
+ HEVC_MAX_SUB_LAYERS = 7,
+ // 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023].
+ HEVC_MAX_LAYER_SETS = 1024,
+
+ // 7.4.2.1: vps_video_parameter_set_id is u(4).
+ HEVC_MAX_VPS_COUNT = 16,
+ // 7.4.3.2.1: sps_seq_parameter_set_id is in [0, 15].
+ HEVC_MAX_SPS_COUNT = 16,
+ // 7.4.3.3.1: pps_pic_parameter_set_id is in [0, 63].
+ HEVC_MAX_PPS_COUNT = 64,
+
+ // A.4.2: MaxDpbSize is bounded above by 16.
+ HEVC_MAX_DPB_SIZE = 16,
+ // 7.4.3.1: vps_max_dec_pic_buffering_minus1[i] is in [0, MaxDpbSize - 1].
+ HEVC_MAX_REFS = HEVC_MAX_DPB_SIZE,
+
+ // 7.4.3.2.1: num_short_term_ref_pic_sets is in [0, 64].
+ HEVC_MAX_SHORT_TERM_REF_PIC_SETS = 64,
+ // 7.4.3.2.1: num_long_term_ref_pics_sps is in [0, 32].
+ HEVC_MAX_LONG_TERM_REF_PICS = 32,
+
+ // A.3: all profiles require that CtbLog2SizeY is in [4, 6].
+ HEVC_MIN_LOG2_CTB_SIZE = 4,
+ HEVC_MAX_LOG2_CTB_SIZE = 6,
+
+ // E.3.2: cpb_cnt_minus1[i] is in [0, 31].
+ HEVC_MAX_CPB_CNT = 32,
+
+ // A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584.
+ HEVC_MAX_LUMA_PS = 35651584,
+ // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+ // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/
+ // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+ HEVC_MAX_WIDTH = 16888,
+ HEVC_MAX_HEIGHT = 16888,
+
+ // A.4.1: table A.6 allows at most 22 tile rows for any level.
+ HEVC_MAX_TILE_ROWS = 22,
+ // A.4.1: table A.6 allows at most 20 tile columns for any level.
+ HEVC_MAX_TILE_COLUMNS = 20,
+
+ // A.4.2: table A.6 allows at most 600 slice segments for any level.
+ HEVC_MAX_SLICE_SEGMENTS = 600,
+
+ // 7.4.7.1: in the worst case (tiles_enabled_flag and
+ // entropy_coding_sync_enabled_flag are both set), entry points can be
+ // placed at the beginning of every Ctb row in every tile, giving an
+ // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
+ // Only a stream with very high resolution and perverse parameters could
+ // get near that, though, so set a lower limit here with the maximum
+ // possible value for 4K video (at most 135 16x16 Ctb rows).
+ HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135,
+
+ // A.3.7: Screen content coding extensions
+ HEVC_MAX_PALETTE_PREDICTOR_SIZE = 128,
+};
+
+
+#endif /* AVCODEC_HEVC_HEVC_H */