1
0
Fork 0

avcodec: remove FF_API_FLAG_TRUNCATED

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2023-01-09 11:22:39 -03:00 committed by Anton Khirnov
parent 5f9e848e68
commit 3ceffe7839
19 changed files with 1 additions and 293 deletions

View File

@ -303,15 +303,6 @@ typedef struct RcOverride{
* error[?] variables will be set during encoding.
*/
#define AV_CODEC_FLAG_PSNR (1 << 15)
#if FF_API_FLAG_TRUNCATED
/**
* Input bitstream might be truncated at a random location
* instead of only at frame boundaries.
*
* @deprecated use codec parsers for packetizing input
*/
#define AV_CODEC_FLAG_TRUNCATED (1 << 16)
#endif
/**
* Use interlaced DCT.
*/

View File

@ -50,12 +50,6 @@
* avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer.
*/
#define AV_CODEC_CAP_DR1 (1 << 1)
#if FF_API_FLAG_TRUNCATED
/**
* @deprecated Use parsers to always send proper frames.
*/
#define AV_CODEC_CAP_TRUNCATED (1 << 3)
#endif
/**
* Encoder or decoder requires flushing with NULL input at the end in order to
* give the complete and correct output.

View File

@ -427,11 +427,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (!got_frame)
av_frame_unref(frame);
#if FF_API_FLAG_TRUNCATED
if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && !(avctx->flags & AV_CODEC_FLAG_TRUNCATED))
#else
if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO)
#endif
ret = pkt->size;
/* do not stop draining when actual_got_frame != 0 or ret < 0 */

View File

@ -25,16 +25,9 @@
*/
#include "parser.h"
#if FF_API_FLAG_TRUNCATED
/* Nuke this header when removing FF_API_FLAG_TRUNCATED */
#include "h263_parser.h"
int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
#else
static int h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
{
#endif
int vop_found, i;
uint32_t state;
@ -80,11 +73,7 @@ static int h263_parse(AVCodecParserContext *s,
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
next = buf_size;
} else {
#if FF_API_FLAG_TRUNCATED
next= ff_h263_find_frame_end(pc, buf, buf_size);
#else
next = h263_find_frame_end(pc, buf, buf_size);
#endif
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL;

View File

@ -1,29 +0,0 @@
/*
* H.263 parser
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
* 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_H263_PARSER_H
#define AVCODEC_H263_PARSER_H
#include "parser.h"
int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
#endif /* AVCODEC_H263_PARSER_H */

View File

@ -36,17 +36,11 @@
#include "flvdec.h"
#include "h263.h"
#include "h263dec.h"
#if FF_API_FLAG_TRUNCATED
#include "h263_parser.h"
#endif
#include "hwconfig.h"
#include "mpeg_er.h"
#include "mpeg4video.h"
#include "mpeg4videodec.h"
#include "mpeg4videodefs.h"
#if FF_API_FLAG_TRUNCATED
#include "mpeg4video_parser.h"
#endif
#include "mpegutils.h"
#include "mpegvideo.h"
#include "mpegvideodec.h"
@ -163,14 +157,6 @@ static int get_consumed_bytes(MpegEncContext *s, int buf_size)
/* We would have to scan through the whole buf to handle the weird
* reordering ... */
return buf_size;
#if FF_API_FLAG_TRUNCATED
} else if (s->avctx->flags & AV_CODEC_FLAG_TRUNCATED) {
pos -= s->parse_context.last_index;
// padding is not really read so this might be -1
if (pos < 0)
pos = 0;
return pos;
#endif
} else {
// avoid infinite loops (maybe not needed...)
if (pos == 0)
@ -448,28 +434,6 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict,
return 0;
}
#if FF_API_FLAG_TRUNCATED
if (s->avctx->flags & AV_CODEC_FLAG_TRUNCATED) {
int next;
if (CONFIG_MPEG4_DECODER && s->codec_id == AV_CODEC_ID_MPEG4) {
next = ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
} else if (CONFIG_H263_DECODER && s->codec_id == AV_CODEC_ID_H263) {
next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
} else if (CONFIG_H263P_DECODER && s->codec_id == AV_CODEC_ID_H263P) {
next = ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
} else {
av_log(s->avctx, AV_LOG_ERROR,
"this codec does not support truncated bitstreams\n");
return AVERROR(ENOSYS);
}
if (ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf,
&buf_size) < 0)
return buf_size;
}
#endif
retry:
if (s->divx_packed && s->bitstream_buffer_size) {
int i;
@ -749,9 +713,6 @@ const FFCodec ff_h263_decoder = {
.close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.flush = ff_mpeg_flush,
@ -770,9 +731,6 @@ const FFCodec ff_h263p_decoder = {
.close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.flush = ff_mpeg_flush,

View File

@ -167,72 +167,6 @@ av_cold void ff_mpeg12_init_vlcs(void)
ff_thread_once(&init_static_once, mpeg12_init_vlcs);
}
#if FF_API_FLAG_TRUNCATED
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
{
int i;
uint32_t state = pc->state;
/* EOF considered as end of frame */
if (buf_size == 0)
return 0;
/*
0 frame start -> 1/4
1 first_SEQEXT -> 0/2
2 first field start -> 3/0
3 second_SEQEXT -> 2/0
4 searching end
*/
for (i = 0; i < buf_size; i++) {
av_assert1(pc->frame_start_found >= 0 && pc->frame_start_found <= 4);
if (pc->frame_start_found & 1) {
if (state == EXT_START_CODE && (buf[i] & 0xF0) != 0x80)
pc->frame_start_found--;
else if (state == EXT_START_CODE + 2) {
if ((buf[i] & 3) == 3)
pc->frame_start_found = 0;
else
pc->frame_start_found = (pc->frame_start_found + 1) & 3;
}
state++;
} else {
i = avpriv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1;
if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) {
i++;
pc->frame_start_found = 4;
}
if (state == SEQ_END_CODE) {
pc->frame_start_found = 0;
pc->state=-1;
return i+1;
}
if (pc->frame_start_found == 2 && state == SEQ_START_CODE)
pc->frame_start_found = 0;
if (pc->frame_start_found < 4 && state == EXT_START_CODE)
pc->frame_start_found++;
if (pc->frame_start_found == 4 && (state & 0xFFFFFF00) == 0x100) {
if (state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE) {
pc->frame_start_found = 0;
pc->state = -1;
return i - 3;
}
}
if (pc->frame_start_found == 0 && s && state == PICTURE_START_CODE) {
ff_fetch_timestamp(s, i - 3, 1, i > 3);
}
}
}
pc->state = state;
return END_NOT_FOUND;
}
#endif
#define MAX_INDEX (64 - 1)
int ff_mpeg1_decode_block_intra(GetBitContext *gb,

View File

@ -34,15 +34,6 @@
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
#include "version_major.h"
#if FF_API_FLAG_TRUNCATED
#include <stdint.h>
struct ParseContext;
struct AVCodecParserContext;
int ff_mpeg1_find_frame_end(struct ParseContext *pc, const uint8_t *buf, int buf_size, struct AVCodecParserContext *s);
#endif
void ff_mpeg12_find_best_frame_rate(AVRational frame_rate,
int *code, int *ext_n, int *ext_d,
int nonstandard);

View File

@ -1239,14 +1239,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
(s1->save_progressive_seq != s->progressive_sequence && FFALIGN(s->height, 16) != FFALIGN(s->height, 32)) ||
0) {
if (s1->mpeg_enc_ctx_allocated) {
#if FF_API_FLAG_TRUNCATED
ParseContext pc = s->parse_context;
s->parse_context.buffer = 0;
ff_mpv_common_end(s);
s->parse_context = pc;
#else
ff_mpv_common_end(s);
#endif
s1->mpeg_enc_ctx_allocated = 0;
}
@ -2482,11 +2475,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture,
if (avctx->err_recognition & AV_EF_EXPLODE && s2->er.error_count)
return AVERROR_INVALIDDATA;
#if FF_API_FLAG_TRUNCATED
return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
#else
return FFMAX(0, buf_ptr - buf);
#endif
}
input_size = buf_end - buf_ptr;
@ -2799,17 +2788,6 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
return buf_size;
}
#if FF_API_FLAG_TRUNCATED
if (s2->avctx->flags & AV_CODEC_FLAG_TRUNCATED) {
int next = ff_mpeg1_find_frame_end(&s2->parse_context, buf,
buf_size, NULL);
if (ff_combine_frame(&s2->parse_context, next,
(const uint8_t **) &buf, &buf_size) < 0)
return buf_size;
}
#endif
if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
|| s2->codec_tag == AV_RL32("BW10")
))
@ -2886,9 +2864,6 @@ const FFCodec ff_mpeg1video_decoder = {
.close = mpeg_decode_end,
FF_CODEC_DECODE_CB(mpeg_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.flush = flush,
@ -2918,9 +2893,6 @@ const FFCodec ff_mpeg2video_decoder = {
.close = mpeg_decode_end,
FF_CODEC_DECODE_CB(mpeg_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.flush = flush,
@ -2963,9 +2935,6 @@ const FFCodec ff_mpegvideo_decoder = {
.close = mpeg_decode_end,
FF_CODEC_DECODE_CB(mpeg_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.flush = flush,

View File

@ -27,10 +27,6 @@
#include "mpegvideo.h"
#include "mpeg4videodec.h"
#include "mpeg4videodefs.h"
#if FF_API_FLAG_TRUNCATED
/* Nuke this header when removing FF_API_FLAG_TRUNCATED */
#include "mpeg4video_parser.h"
#endif
struct Mp4vParseContext {
ParseContext pc;
@ -38,15 +34,11 @@ struct Mp4vParseContext {
int first_picture;
};
#if FF_API_FLAG_TRUNCATED
int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
#else
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
static int mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
#endif
{
int vop_found, i;
uint32_t state;
@ -148,11 +140,7 @@ static int mpeg4video_parse(AVCodecParserContext *s,
if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
next = buf_size;
} else {
#if FF_API_FLAG_TRUNCATED
next = ff_mpeg4_find_frame_end(pc, buf, buf_size);
#else
next = mpeg4_find_frame_end(pc, buf, buf_size);
#endif
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL;

View File

@ -1,34 +0,0 @@
/*
* MPEG-4 video parser prototypes
* 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_MPEG4VIDEO_PARSER_H
#define AVCODEC_MPEG4VIDEO_PARSER_H
#include "parser.h"
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
*/
int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
#endif /* AVCODEC_MPEG4VIDEO_PARSER_H */

View File

@ -3859,9 +3859,6 @@ const FFCodec ff_mpeg4_decoder = {
.close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
#if FF_API_FLAG_TRUNCATED
AV_CODEC_CAP_TRUNCATED |
#endif
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
FF_CODEC_CAP_ALLOCATE_PROGRESS,

View File

@ -738,10 +738,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
nb_slices = max_slices;
}
#if FF_API_FLAG_TRUNCATED
s->parse_context.state = -1;
#endif
s->context_initialized = 1;
memset(s->thread_context, 0, sizeof(s->thread_context));
s->thread_context[0] = s;
@ -791,11 +787,6 @@ void ff_mpv_common_end(MpegEncContext *s)
if (s->slice_context_count > 1)
s->slice_context_count = 1;
#if FF_API_FLAG_TRUNCATED
av_freep(&s->parse_context.buffer);
s->parse_context.buffer_size = 0;
#endif
av_freep(&s->bitstream_buffer);
s->allocated_bitstream_buffer_size = 0;

View File

@ -44,9 +44,6 @@
#include "pixblockdsp.h"
#include "put_bits.h"
#include "ratecontrol.h"
#if FF_API_FLAG_TRUNCATED
#include "parser.h"
#endif
#include "mpegutils.h"
#include "qpeldsp.h"
#include "videodsp.h"
@ -353,10 +350,6 @@ typedef struct MpegEncContext {
GetBitContext last_resync_gb; ///< used to search for the next resync marker
int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only)
#if FF_API_FLAG_TRUNCATED
ParseContext parse_context;
#endif
/* H.263 specific */
int gob_index;
int obmc; ///< overlapped block motion compensation

View File

@ -554,14 +554,6 @@ void ff_mpeg_flush(AVCodecContext *avctx)
s->mb_x = s->mb_y = 0;
#if FF_API_FLAG_TRUNCATED
s->parse_context.state = -1;
s->parse_context.frame_start_found = 0;
s->parse_context.overread = 0;
s->parse_context.overread_index = 0;
s->parse_context.index = 0;
s->parse_context.last_index = 0;
#endif
s->bitstream_buffer_size = 0;
s->pp_time = 0;
}

View File

@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/avassert.h"
#include "decode.h"
#include "parser.h"
#include "mpeg12.h"
@ -33,7 +34,6 @@ struct MpvParseContext {
int width, height;
};
#if !FF_API_FLAG_TRUNCATED
/**
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or -1
@ -98,7 +98,6 @@ static int mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf,
pc->state = state;
return END_NOT_FOUND;
}
#endif
static void mpegvideo_extract_headers(AVCodecParserContext *s,
AVCodecContext *avctx,
@ -255,11 +254,7 @@ static int mpegvideo_parse(AVCodecParserContext *s,
if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
next= buf_size;
}else{
#if FF_API_FLAG_TRUNCATED
next= ff_mpeg1_find_frame_end(pc, buf, buf_size, s);
#else
next = mpeg1_find_frame_end(pc, buf, buf_size, s);
#endif
if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
*poutbuf = NULL;

View File

@ -64,9 +64,6 @@ static const AVOption avcodec_options[] = {
{"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"},
{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"},
{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"},
#if FF_API_FLAG_TRUNCATED
{"truncated", "(Deprecated, use parsers instead.) Input bitstream might be randomly truncated", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, V|D | AV_OPT_FLAG_DEPRECATED, "flags"},
#endif
{"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"},
{"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"},
{"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"},

View File

@ -48,9 +48,6 @@
static void validate_thread_parameters(AVCodecContext *avctx)
{
int frame_threading_supported = (avctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS)
#if FF_API_FLAG_TRUNCATED
&& !(avctx->flags & AV_CODEC_FLAG_TRUNCATED)
#endif
&& !(avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
&& !(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS);
if (avctx->thread_count == 1) {

View File

@ -38,7 +38,6 @@
*/
#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60)
#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60)