Message ID | 20220824084318.333-10-anton@khirnov.net |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,01/18] tests/fate/mov: add a test for dv audio demuxed through dv demuxer | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | fail | Make fate failed |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | fail | Make fate failed |
Anton Khirnov: > dv.h is also used by libavformat, so avoid exposing encoder/decoder code > to it. > --- > libavcodec/dv.c | 8 ++++-- > libavcodec/dv.h | 34 ---------------------- > libavcodec/dv_internal.h | 62 ++++++++++++++++++++++++++++++++++++++++ > libavcodec/dvdec.c | 1 + > libavcodec/dvenc.c | 1 + > 5 files changed, 70 insertions(+), 36 deletions(-) > create mode 100644 libavcodec/dv_internal.h > > diff --git a/libavcodec/dv.c b/libavcodec/dv.c > index b5e54de5dd..eb49978ad8 100644 > --- a/libavcodec/dv.c > +++ b/libavcodec/dv.c > @@ -38,8 +38,12 @@ > * DV codec. > */ > > -#include "avcodec.h" > -#include "dv.h" > +#include <stdint.h> > + > +#include "libavutil/pixfmt.h" > + > +#include "dv_internal.h" > +#include "dv_profile.h" > > static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, > int seq, int slot, uint16_t *tbl) > diff --git a/libavcodec/dv.h b/libavcodec/dv.h > index 859a4e6545..535f01cf0b 100644 > --- a/libavcodec/dv.h > +++ b/libavcodec/dv.h > @@ -27,13 +27,6 @@ > #ifndef AVCODEC_DV_H > #define AVCODEC_DV_H > > -#include "dv_profile.h" > - > -typedef struct DVwork_chunk { > - uint16_t buf_offset; > - uint16_t mb_coordinates[5]; > -} DVwork_chunk; > - > enum dv_section_type { > dv_sect_header = 0x1f, > dv_sect_subcode = 0x3f, > @@ -72,31 +65,4 @@ enum dv_pack_type { > */ > #define DV_MAX_BPM 8 > > -int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); > - > -static inline int dv_work_pool_size(const AVDVProfile *d) > -{ > - int size = d->n_difchan * d->difseg_size * 27; > - if (DV_PROFILE_IS_1080i50(d)) > - size -= 3 * 27; > - if (DV_PROFILE_IS_720p50(d)) > - size -= 4 * 27; > - return size; > -} > - > -static inline void dv_calculate_mb_xy(const AVDVProfile *sys, > - const uint8_t *buf, > - const DVwork_chunk *work_chunk, > - int m, int *mb_x, int *mb_y) > -{ > - *mb_x = work_chunk->mb_coordinates[m] & 0xff; > - *mb_y = work_chunk->mb_coordinates[m] >> 8; > - > - /* We work with 720p frames split in half. > - * The odd half-frame (chan == 2,3) is displaced :-( */ > - if (sys->height == 720 && !(buf[1] & 0x0C)) > - /* shifting the Y coordinate down by 72/2 macro blocks */ > - *mb_y -= (*mb_y > 17) ? 18 : -72; > -} > - > #endif /* AVCODEC_DV_H */ > diff --git a/libavcodec/dv_internal.h b/libavcodec/dv_internal.h > new file mode 100644 > index 0000000000..4b4151c88d > --- /dev/null > +++ b/libavcodec/dv_internal.h > @@ -0,0 +1,62 @@ > +/* > + * DV encoder/decoder shared code > + * Copyright (c) 2002 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 > + */ > + > +#ifndef AVCODEC_DV_INTERNAL_H > +#define AVCODEC_DV_INTERNAL_H > + > +#include <stdint.h> > + > +#include "dv.h" > +#include "dv_profile.h" > + > +typedef struct DVwork_chunk { > + uint16_t buf_offset; > + uint16_t mb_coordinates[5]; > +} DVwork_chunk; > + > +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); > + > +static inline int dv_work_pool_size(const AVDVProfile *d) > +{ > + int size = d->n_difchan * d->difseg_size * 27; > + if (DV_PROFILE_IS_1080i50(d)) > + size -= 3 * 27; > + if (DV_PROFILE_IS_720p50(d)) > + size -= 4 * 27; > + return size; > +} > + > +static inline void dv_calculate_mb_xy(const AVDVProfile *sys, > + const uint8_t *buf, > + const DVwork_chunk *work_chunk, > + int m, int *mb_x, int *mb_y) > +{ > + *mb_x = work_chunk->mb_coordinates[m] & 0xff; > + *mb_y = work_chunk->mb_coordinates[m] >> 8; > + > + /* We work with 720p frames split in half. > + * The odd half-frame (chan == 2,3) is displaced :-( */ > + if (sys->height == 720 && !(buf[1] & 0x0C)) > + /* shifting the Y coordinate down by 72/2 macro blocks */ > + *mb_y -= (*mb_y > 17) ? 18 : -72; > +} > + > +#endif // AVCODEC_DV_INTERNAL_H > diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c > index 444b137488..297bf7f2fb 100644 > --- a/libavcodec/dvdec.c > +++ b/libavcodec/dvdec.c > @@ -45,6 +45,7 @@ > #include "avcodec.h" > #include "codec_internal.h" > #include "dv.h" > +#include "dv_internal.h" > #include "dv_profile_internal.h" > #include "dvdata.h" > #include "get_bits.h" > diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c > index 19291724e0..1f0374b865 100644 > --- a/libavcodec/dvenc.c > +++ b/libavcodec/dvenc.c > @@ -38,6 +38,7 @@ > #include "avcodec.h" > #include "codec_internal.h" > #include "dv.h" > +#include "dv_internal.h" > #include "dv_profile_internal.h" > #include "dv_tablegen.h" > #include "encode.h" LGTM (I pondered doing something like this, but couldn't come up with a good name for the header. I was fixated on "dv_codecs.h" given that this would be the common code for the codecs, but that sounded strange.) - Andreas
diff --git a/libavcodec/dv.c b/libavcodec/dv.c index b5e54de5dd..eb49978ad8 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -38,8 +38,12 @@ * DV codec. */ -#include "avcodec.h" -#include "dv.h" +#include <stdint.h> + +#include "libavutil/pixfmt.h" + +#include "dv_internal.h" +#include "dv_profile.h" static inline void dv_calc_mb_coordinates(const AVDVProfile *d, int chan, int seq, int slot, uint16_t *tbl) diff --git a/libavcodec/dv.h b/libavcodec/dv.h index 859a4e6545..535f01cf0b 100644 --- a/libavcodec/dv.h +++ b/libavcodec/dv.h @@ -27,13 +27,6 @@ #ifndef AVCODEC_DV_H #define AVCODEC_DV_H -#include "dv_profile.h" - -typedef struct DVwork_chunk { - uint16_t buf_offset; - uint16_t mb_coordinates[5]; -} DVwork_chunk; - enum dv_section_type { dv_sect_header = 0x1f, dv_sect_subcode = 0x3f, @@ -72,31 +65,4 @@ enum dv_pack_type { */ #define DV_MAX_BPM 8 -int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); - -static inline int dv_work_pool_size(const AVDVProfile *d) -{ - int size = d->n_difchan * d->difseg_size * 27; - if (DV_PROFILE_IS_1080i50(d)) - size -= 3 * 27; - if (DV_PROFILE_IS_720p50(d)) - size -= 4 * 27; - return size; -} - -static inline void dv_calculate_mb_xy(const AVDVProfile *sys, - const uint8_t *buf, - const DVwork_chunk *work_chunk, - int m, int *mb_x, int *mb_y) -{ - *mb_x = work_chunk->mb_coordinates[m] & 0xff; - *mb_y = work_chunk->mb_coordinates[m] >> 8; - - /* We work with 720p frames split in half. - * The odd half-frame (chan == 2,3) is displaced :-( */ - if (sys->height == 720 && !(buf[1] & 0x0C)) - /* shifting the Y coordinate down by 72/2 macro blocks */ - *mb_y -= (*mb_y > 17) ? 18 : -72; -} - #endif /* AVCODEC_DV_H */ diff --git a/libavcodec/dv_internal.h b/libavcodec/dv_internal.h new file mode 100644 index 0000000000..4b4151c88d --- /dev/null +++ b/libavcodec/dv_internal.h @@ -0,0 +1,62 @@ +/* + * DV encoder/decoder shared code + * Copyright (c) 2002 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 + */ + +#ifndef AVCODEC_DV_INTERNAL_H +#define AVCODEC_DV_INTERNAL_H + +#include <stdint.h> + +#include "dv.h" +#include "dv_profile.h" + +typedef struct DVwork_chunk { + uint16_t buf_offset; + uint16_t mb_coordinates[5]; +} DVwork_chunk; + +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d); + +static inline int dv_work_pool_size(const AVDVProfile *d) +{ + int size = d->n_difchan * d->difseg_size * 27; + if (DV_PROFILE_IS_1080i50(d)) + size -= 3 * 27; + if (DV_PROFILE_IS_720p50(d)) + size -= 4 * 27; + return size; +} + +static inline void dv_calculate_mb_xy(const AVDVProfile *sys, + const uint8_t *buf, + const DVwork_chunk *work_chunk, + int m, int *mb_x, int *mb_y) +{ + *mb_x = work_chunk->mb_coordinates[m] & 0xff; + *mb_y = work_chunk->mb_coordinates[m] >> 8; + + /* We work with 720p frames split in half. + * The odd half-frame (chan == 2,3) is displaced :-( */ + if (sys->height == 720 && !(buf[1] & 0x0C)) + /* shifting the Y coordinate down by 72/2 macro blocks */ + *mb_y -= (*mb_y > 17) ? 18 : -72; +} + +#endif // AVCODEC_DV_INTERNAL_H diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index 444b137488..297bf7f2fb 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -45,6 +45,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dvdata.h" #include "get_bits.h" diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 19291724e0..1f0374b865 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -38,6 +38,7 @@ #include "avcodec.h" #include "codec_internal.h" #include "dv.h" +#include "dv_internal.h" #include "dv_profile_internal.h" #include "dv_tablegen.h" #include "encode.h"