1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

avcodec: Remove deprecated AVPicture API

Deprecated in a17a766190.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2021-02-26 06:19:42 +01:00 committed by James Almer
parent af581cf79d
commit d947464ad4
14 changed files with 1 additions and 482 deletions

View File

@ -32,7 +32,6 @@ OBJS = ac3_parser.o \
avcodec.o \
avdct.o \
avpacket.o \
avpicture.o \
bitstream.o \
bitstream_filters.o \
bsf.o \
@ -1214,7 +1213,6 @@ TESTPROGS = avpacket \
celp_math \
codec_desc \
htmlsubtitles \
imgconvert \
jpeg2000dwt \
mathops \
utils \

View File

@ -2418,33 +2418,6 @@ typedef struct AVHWAccel {
* @}
*/
#if FF_API_AVPICTURE
/**
* @defgroup lavc_picture AVPicture
*
* Functions for working with AVPicture
* @{
*/
/**
* Picture data structure.
*
* Up to four components can be stored into it, the last component is
* alpha.
* @deprecated use AVFrame or imgutils functions instead
*/
typedef struct AVPicture {
attribute_deprecated
uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes
attribute_deprecated
int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
} AVPicture;
/**
* @}
*/
#endif
enum AVSubtitleType {
SUBTITLE_NONE,
@ -2472,13 +2445,6 @@ typedef struct AVSubtitleRect {
int h; ///< height of pict, undefined when pict is not set
int nb_colors; ///< number of colors in pict, undefined when pict is not set
#if FF_API_AVPICTURE
/**
* @deprecated unused
*/
attribute_deprecated
AVPicture pict;
#endif
/**
* data+linesize for the bitmap of this subtitle.
* Can be set for text/ass as well once they are rendered.
@ -3445,71 +3411,6 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
* @}
*/
#if FF_API_AVPICTURE
/**
* @addtogroup lavc_picture
* @{
*/
/**
* @deprecated unused
*/
attribute_deprecated
int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
/**
* @deprecated unused
*/
attribute_deprecated
void avpicture_free(AVPicture *picture);
/**
* @deprecated use av_image_fill_arrays() instead.
*/
attribute_deprecated
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
enum AVPixelFormat pix_fmt, int width, int height);
/**
* @deprecated use av_image_copy_to_buffer() instead.
*/
attribute_deprecated
int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt,
int width, int height,
unsigned char *dest, int dest_size);
/**
* @deprecated use av_image_get_buffer_size() instead.
*/
attribute_deprecated
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
/**
* @deprecated av_image_copy() instead.
*/
attribute_deprecated
void av_picture_copy(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int width, int height);
/**
* @deprecated unused
*/
attribute_deprecated
int av_picture_crop(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int top_band, int left_band);
/**
* @deprecated unused
*/
attribute_deprecated
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
int padtop, int padbottom, int padleft, int padright, int *color);
/**
* @}
*/
#endif
/**
* @defgroup lavc_misc Utility functions
* @ingroup libavc

View File

@ -1,82 +0,0 @@
/*
* AVPicture management routines
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
*
* 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
*/
/**
* @file
* AVPicture management routines
*/
#include "avcodec.h"
#include "internal.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/colorspace.h"
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
enum AVPixelFormat pix_fmt, int width, int height)
{
return av_image_fill_arrays(picture->data, picture->linesize,
ptr, pix_fmt, width, height, 1);
}
int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, int width, int height,
unsigned char *dest, int dest_size)
{
return av_image_copy_to_buffer(dest, dest_size,
(const uint8_t * const*)src->data, src->linesize,
pix_fmt, width, height, 1);
}
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
{
return av_image_get_buffer_size(pix_fmt, width, height, 1);
}
int avpicture_alloc(AVPicture *picture,
enum AVPixelFormat pix_fmt, int width, int height)
{
int ret = av_image_alloc(picture->data, picture->linesize,
width, height, pix_fmt, 1);
if (ret < 0) {
memset(picture, 0, sizeof(AVPicture));
return ret;
}
return 0;
}
void avpicture_free(AVPicture *picture)
{
av_freep(&picture->data[0]);
}
void av_picture_copy(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int width, int height)
{
av_image_copy(dst->data, dst->linesize, (const uint8_t **)src->data,
src->linesize, pix_fmt, width, height);
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_AVPICTURE */

View File

@ -832,18 +832,6 @@ static int save_subtitle_set(AVCodecContext *avctx, AVSubtitle *sub, int *got_ou
memcpy(rect->data[1], region->computed_clut, sizeof(region->computed_clut));
}
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
int j;
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
i++;
}
}

View File

@ -409,15 +409,6 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->linesize[0] = w;
sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
for (i = 0; i < 4; i++) {
sub_header->rects[0]->pict.data[i] = sub_header->rects[0]->data[i];
sub_header->rects[0]->pict.linesize[i] = sub_header->rects[0]->linesize[i];
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
}
if (next_cmd_pos < cmd_pos) {
@ -504,15 +495,6 @@ static int find_smallest_bounding_rectangle(DVDSubContext *ctx, AVSubtitle *s)
s->rects[0]->x += x1;
s->rects[0]->y += y1;
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
for (i = 0; i < 4; i++) {
s->rects[0]->pict.data[i] = s->rects[0]->data[i];
s->rects[0]->pict.linesize[i] = s->rects[0]->linesize[i];
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return 1;
}

View File

@ -279,20 +279,6 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
break;
}
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
for (i = 0; i < rects; i++)
if (!h->rects[i]->data[0]) {
AVSubtitleRect *rect = h->rects[i];
int j;
for (j = 0; j < 4; j++) {
rect->data[j] = rect->pict.data[j];
rect->linesize[j] = rect->pict.linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
vrect = *h->rects[0];
if (rects > 1) {

View File

@ -25,13 +25,8 @@
*/
#include "avcodec.h"
#include "internal.h"
#include "mathops.h"
#include "libavutil/colorspace.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h"
#if FF_API_AVCODEC_PIX_FMT
int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
@ -72,152 +67,3 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p
return best;
}
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
/* return true if yuv planar */
static inline int is_yuv_planar(const AVPixFmtDescriptor *desc)
{
int i;
int planes[4] = { 0 };
if ( desc->flags & AV_PIX_FMT_FLAG_RGB
|| !(desc->flags & AV_PIX_FMT_FLAG_PLANAR))
return 0;
/* set the used planes */
for (i = 0; i < desc->nb_components; i++)
planes[desc->comp[i].plane] = 1;
/* if there is an unused plane, the format is not planar */
for (i = 0; i < desc->nb_components; i++)
if (!planes[i])
return 0;
return 1;
}
int av_picture_crop(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int top_band, int left_band)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int y_shift;
int x_shift;
int max_step[4];
if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
return -1;
y_shift = desc->log2_chroma_h;
x_shift = desc->log2_chroma_w;
av_image_fill_max_pixsteps(max_step, NULL, desc);
if (is_yuv_planar(desc)) {
dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
} else{
if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
return -1;
dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + (left_band * max_step[0]);
}
dst->linesize[0] = src->linesize[0];
dst->linesize[1] = src->linesize[1];
dst->linesize[2] = src->linesize[2];
return 0;
}
int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
int *color)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
uint8_t *optr;
int y_shift;
int x_shift;
int yheight;
int i, y;
int max_step[4];
if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
return -1;
if (!is_yuv_planar(desc)) {
if (src)
return -1; //TODO: Not yet implemented
av_image_fill_max_pixsteps(max_step, NULL, desc);
if (padtop || padleft) {
memset(dst->data[0], color[0],
dst->linesize[0] * padtop + (padleft * max_step[0]));
}
if (padleft || padright) {
optr = dst->data[0] + dst->linesize[0] * padtop +
(dst->linesize[0] - (padright * max_step[0]));
yheight = height - 1 - (padtop + padbottom);
for (y = 0; y < yheight; y++) {
memset(optr, color[0], (padleft + padright) * max_step[0]);
optr += dst->linesize[0];
}
}
if (padbottom || padright) {
optr = dst->data[0] + dst->linesize[0] * (height - padbottom) -
(padright * max_step[0]);
memset(optr, color[0], dst->linesize[0] * padbottom +
(padright * max_step[0]));
}
return 0;
}
for (i = 0; i < 3; i++) {
x_shift = i ? desc->log2_chroma_w : 0;
y_shift = i ? desc->log2_chroma_h : 0;
if (padtop || padleft) {
memset(dst->data[i], color[i],
dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
}
if (padleft || padright) {
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift);
optr += dst->linesize[i];
}
}
if (src) { /* first line */
uint8_t *iptr = src->data[i];
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(padleft >> x_shift);
memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
iptr += src->linesize[i];
optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
(dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift);
memcpy(optr + ((padleft + padright) >> x_shift), iptr,
(width - padleft - padright) >> x_shift);
iptr += src->linesize[i];
optr += dst->linesize[i];
}
}
if (padbottom || padright) {
optr = dst->data[i] + dst->linesize[i] *
((height - padbottom) >> y_shift) - (padright >> x_shift);
memset(optr, color[i],dst->linesize[i] *
(padbottom >> y_shift) + (padright >> x_shift));
}
}
return 0;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_AVPICTURE */

View File

@ -641,7 +641,6 @@ static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *got_sub
TeletextContext *ctx = avctx->priv_data;
AVSubtitle *sub = data;
int ret = 0;
int j;
if (!ctx->vbi) {
if (!(ctx->vbi = vbi_decoder_new()))
@ -701,14 +700,6 @@ static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *got_sub
if (sub->rects) {
sub->num_rects = 1;
sub->rects[0] = ctx->pages->sub_rect;
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
for (j = 0; j < 4; j++) {
sub->rects[0]->pict.data[j] = sub->rects[0]->data[j];
sub->rects[0]->pict.linesize[j] = sub->rects[0]->linesize[j];
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} else {
ret = AVERROR(ENOMEM);
}

View File

@ -596,20 +596,6 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
if (!ctx->forced_subs_only || ctx->presentation.objects[i].composition_flag & 0x40)
memcpy(sub->rects[i]->data[1], palette->clut, sub->rects[i]->nb_colors * sizeof(uint32_t));
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
AVSubtitleRect *rect;
int j;
rect = sub->rects[i];
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
return 1;
}

View File

@ -11,7 +11,6 @@
/h265_levels
/htmlsubtitles
/iirfilter
/imgconvert
/jpeg2000dwt
/mathops
/mjpegenc_huffman

View File

@ -1,46 +0,0 @@
/*
* Misc image conversion routines
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
*
* 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 "libavcodec/imgconvert.c"
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
int main(void){
int i;
int err=0;
int skip = 0;
for (i=0; i<AV_PIX_FMT_NB*2; i++) {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
if(!desc || !desc->name) {
skip ++;
continue;
}
if (skip) {
av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip);
skip = 0;
}
av_log(NULL, AV_LOG_INFO, "pix fmt %s yuv_plan:%d avg_bpp:%d\n", desc->name, is_yuv_planar(desc), av_get_padded_bits_per_pixel(desc));
}
return err;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_AVPICTURE */

View File

@ -54,9 +54,6 @@
#ifndef FF_API_CODED_FRAME
#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_AVPICTURE
#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#ifndef FF_API_VBV_DELAY
#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59)
#endif

View File

@ -134,20 +134,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr,
((uint32_t *)sub->rects[0]->data[1])[i] |= (unsigned)*buf++ << 24;
}
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
{
AVSubtitleRect *rect;
int j;
rect = sub->rects[0];
for (j = 0; j < 4; j++) {
rect->pict.data[j] = rect->data[j];
rect->pict.linesize[j] = rect->linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
// process RLE-compressed data
if ((ret = init_get_bits8(&gb, buf, buf_end - buf)) < 0)
return ret;

View File

@ -132,19 +132,6 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
if (h->num_rects != 1)
av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects);
#if FF_API_AVPICTURE
FF_DISABLE_DEPRECATION_WARNINGS
if (!h->rects[0]->data[0]) {
AVSubtitleRect *rect = h->rects[0];
int j;
for (j = 0; j < 4; j++) {
rect->data[j] = rect->pict.data[j];
rect->linesize[j] = rect->pict.linesize[j];
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
// TODO: render text-based subtitles into bitmaps
if (!h->rects[0]->data[0] || !h->rects[0]->data[1]) {
av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n");