[FFmpeg-devel] [PATCH 14/21] avcodec/internal: Move ff_reget_buffer() to decode.h

2022-08-24 Thread Andreas Rheinhardt
Only used by decoders.

Also clean up the headers a bit while removing now unnecessary
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aasc.c  | 4 +---
 libavcodec/anm.c   | 2 +-
 libavcodec/ansi.c  | 1 +
 libavcodec/argo.c  | 5 +
 libavcodec/avs.c   | 1 +
 libavcodec/bethsoftvideo.c | 2 +-
 libavcodec/bink.c  | 1 +
 libavcodec/c93.c   | 1 +
 libavcodec/cdgraphics.c| 1 +
 libavcodec/cdtoons.c   | 2 +-
 libavcodec/cinepak.c   | 2 --
 libavcodec/clearvideo.c| 1 +
 libavcodec/cpia.c  | 4 ++--
 libavcodec/cscd.c  | 4 +---
 libavcodec/decode.h| 7 +++
 libavcodec/dsicinvideo.c   | 2 +-
 libavcodec/fic.c   | 2 +-
 libavcodec/flashsv.c   | 1 +
 libavcodec/flicvideo.c | 4 +---
 libavcodec/gifdec.c| 1 +
 libavcodec/imx.c   | 1 -
 libavcodec/indeo2.c| 3 +--
 libavcodec/internal.h  | 7 ---
 libavcodec/jvdec.c | 1 +
 libavcodec/lscrdec.c   | 2 +-
 libavcodec/midivid.c   | 7 +--
 libavcodec/mmvideo.c   | 2 +-
 libavcodec/mobiclip.c  | 4 ++--
 libavcodec/motionpixels.c  | 2 +-
 libavcodec/msrle.c | 3 ---
 libavcodec/mss1.c  | 2 +-
 libavcodec/mss2.c  | 1 +
 libavcodec/mss3.c  | 2 +-
 libavcodec/mss4.c  | 2 +-
 libavcodec/msvideo1.c  | 3 ---
 libavcodec/nuv.c   | 1 +
 libavcodec/pafvideo.c  | 2 +-
 libavcodec/qtrle.c | 3 ---
 libavcodec/roqvideodec.c   | 3 +--
 libavcodec/rpza.c  | 5 +
 libavcodec/rscc.c  | 1 -
 libavcodec/scpr.c  | 1 +
 libavcodec/screenpresso.c  | 3 +--
 libavcodec/smacker.c   | 1 +
 libavcodec/smc.c   | 4 
 libavcodec/tiertexseqv.c   | 1 +
 libavcodec/truemotion1.c   | 1 +
 libavcodec/truemotion2.c   | 2 +-
 libavcodec/tscc.c  | 4 
 libavcodec/tscc2.c | 2 +-
 libavcodec/ulti.c  | 6 +-
 libavcodec/vmnc.c  | 6 +-
 libavcodec/vqavideo.c  | 1 +
 libavcodec/wcmv.c  | 4 +---
 libavcodec/xxan.c  | 2 +-
 libavcodec/yop.c   | 3 +--
 56 files changed, 55 insertions(+), 91 deletions(-)

diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c
index d6afa35b86..db9fc834b7 100644
--- a/libavcodec/aasc.c
+++ b/libavcodec/aasc.c
@@ -24,13 +24,11 @@
  * Autodesk RLE Video Decoder by Konstantin Shishkov
  */
 
-#include 
-#include 
 #include 
 
 #include "avcodec.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "msrledec.h"
 
 typedef struct AascContext {
diff --git a/libavcodec/anm.c b/libavcodec/anm.c
index a66ee1e65b..c7256fe6d3 100644
--- a/libavcodec/anm.c
+++ b/libavcodec/anm.c
@@ -27,7 +27,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct AnmContext {
 AVFrame *frame;
diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c
index a6b15c728f..1cd9ebceba 100644
--- a/libavcodec/ansi.c
+++ b/libavcodec/ansi.c
@@ -31,6 +31,7 @@
 #include "avcodec.h"
 #include "cga_data.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "internal.h"
 
 #define ATTR_BOLD 0x01  /**< Bold/Bright-foreground (mode 1) */
diff --git a/libavcodec/argo.c b/libavcodec/argo.c
index b772e9c565..a863373af2 100644
--- a/libavcodec/argo.c
+++ b/libavcodec/argo.c
@@ -19,18 +19,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include 
-#include 
 #include 
 
-#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct ArgoContext {
 GetByteContext gb;
diff --git a/libavcodec/avs.c b/libavcodec/avs.c
index 20c07aeeed..86a41a31be 100644
--- a/libavcodec/avs.c
+++ b/libavcodec/avs.c
@@ -21,6 +21,7 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "internal.h"
 
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
index a2e8f412d6..ea5016bae5 100644
--- a/libavcodec/bethsoftvideo.c
+++ b/libavcodec/bethsoftvideo.c
@@ -32,7 +32,7 @@
 #include "bethsoftvideo.h"
 #include "bytestream.h"
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 
 typedef struct BethsoftvidContext {
 AVFrame *frame;
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 09be0488de..e6d9bdc2fa 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -32,6 +32,7 @@
 #include "binkdsp.h"
 #include "blockdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "hpeldsp.h"
 #include "internal.h"
diff --git a/libavcodec/c93.c b/libavcodec/c93.c
index 196b95e428..871ae589e6 100644
--- a/libavcodec/c93.c
+++ b/libavcodec/c93.c
@@ -22,6 +22,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include 

[FFmpeg-devel] [PATCH 13/21] avcodec/internal: Move ff_get_format() to decode.h

2022-08-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/decode.h   | 13 +
 libavcodec/h263dec.c  |  1 +
 libavcodec/internal.h | 13 -
 libavcodec/mediacodecdec_common.c |  1 +
 libavcodec/pthread_frame.c|  1 +
 libavcodec/utils.c|  1 +
 libavcodec/vc1dec.c   |  1 +
 libavcodec/vp8.c  |  1 +
 8 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index f7828fbff4..81767f73fd 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -99,4 +99,17 @@ int ff_copy_palette(void *dst, const AVPacket *src, void 
*logctx);
  */
 int ff_decode_preinit(AVCodecContext *avctx);
 
+/**
+ * Select the (possibly hardware accelerated) pixel format.
+ * This is a wrapper around AVCodecContext.get_format() and should be used
+ * instead of calling get_format() directly.
+ *
+ * The list of pixel formats must contain at least one valid entry, and is
+ * terminated with AV_PIX_FMT_NONE.  If it is possible to decode to software,
+ * the last entry in the list must be the most accurate software format.
+ * If it is not possible to decode to software, AVCodecContext.sw_pix_fmt
+ * must be set before calling this function.
+ */
+int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
+
 #endif /* AVCODEC_DECODE_H */
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 8728cfa6e9..87fbf87c8a 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -31,6 +31,7 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "error_resilience.h"
 #include "flvdec.h"
 #include "h263.h"
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 61d395e8c9..03b200c444 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -249,19 +249,6 @@ int ff_set_sar(AVCodecContext *avctx, AVRational sar);
 int ff_side_data_update_matrix_encoding(AVFrame *frame,
 enum AVMatrixEncoding matrix_encoding);
 
-/**
- * Select the (possibly hardware accelerated) pixel format.
- * This is a wrapper around AVCodecContext.get_format() and should be used
- * instead of calling get_format() directly.
- *
- * The list of pixel formats must contain at least one valid entry, and is
- * terminated with AV_PIX_FMT_NONE.  If it is possible to decode to software,
- * the last entry in the list must be the most accurate software format.
- * If it is not possible to decode to software, AVCodecContext.sw_pix_fmt
- * must be set before calling this function.
- */
-int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
-
 /**
  * Add a CPB properties side data to an encoding context.
  */
diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index cb18aed401..7952c3c34c 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -32,6 +32,7 @@
 #include "libavutil/timestamp.h"
 
 #include "avcodec.h"
+#include "decode.h"
 #include "internal.h"
 
 #include "mediacodec.h"
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 726bd1bcc7..08a6f98898 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -29,6 +29,7 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "hwconfig.h"
 #include "internal.h"
 #include "pthread_internal.h"
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index e73e3a7d08..2f57418ff7 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -36,6 +36,7 @@
 #include "avcodec.h"
 #include "codec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "hwconfig.h"
 #include "thread.h"
 #include "threadframe.h"
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index b53490b3ab..065b43cb11 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -31,6 +31,7 @@
 #include "avcodec.h"
 #include "blockdsp.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "get_bits.h"
 #include "hwconfig.h"
 #include "internal.h"
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 7a151feb79..6bf846dbfe 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -31,6 +31,7 @@
 
 #include "avcodec.h"
 #include "codec_internal.h"
+#include "decode.h"
 #include "hwconfig.h"
 #include "internal.h"
 #include "mathops.h"
-- 
2.34.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 12/21] avcodec/roqvideoenc: Remove internal.h inclusion

2022-08-24 Thread Andreas Rheinhardt
Possible since c954cf1e1b766a0d1992d5be0a8be0055a8e1a6a.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/roqvideoenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 0a418c3b89..9f03107d81 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -64,7 +64,6 @@
 #include "codec_internal.h"
 #include "elbg.h"
 #include "encode.h"
-#include "internal.h"
 #include "mathops.h"
 
 #define CHROMA_BIAS 1
-- 
2.34.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple values and TIPL frames

2022-08-24 Thread Soft Works



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> rcombs
> Sent: Thursday, August 25, 2022 1:52 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 3/3] lavf/id3v2dec: support multiple
> values and TIPL frames
> 
> Fixes https://trac.ffmpeg.org/ticket/6949
> 
> Ordinary text frames in ID3v2 are allowed to have multiple
> (null-separated) values. This technically isn't allowed in TXXX,
> but it's used in practice by Picard, and supporting it is harmless.
> 
> TIPL/IPL (Involved People List) and TMCL (Musician Credits List) work
> similarly to TXXX, but alternate key-value-key-value.
> ---
>  libavformat/id3v2.c | 49 ++-
> --
>  1 file changed, 28 insertions(+), 21 deletions(-)
> 
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 191a305ffb..335a1436b2 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -321,8 +321,12 @@ static void read_ttag(AVFormatContext *s,
> AVIOContext *pb, int taglen,
>AVDictionary **metadata, const char *key)
>  {
>  uint8_t *dst;
> -int encoding, dict_flags = AV_DICT_DONT_OVERWRITE |
> AV_DICT_DONT_STRDUP_VAL;
> +uint8_t *dst_key = NULL;
> +int encoding, dict_flags = AV_DICT_MULTIKEY |
> AV_DICT_DONT_STRDUP_VAL | AV_DICT_DEDUP;
>  unsigned genre;
> +int count = 0;
> +int is_tipl = !(strcmp(key, "TIPL") && strcmp(key, "TMCL") &&
> +strcmp(key, "IPL"));
> 
>  if (taglen < 1)
>  return;
> @@ -330,30 +334,33 @@ static void read_ttag(AVFormatContext *s,
> AVIOContext *pb, int taglen,
>  encoding = avio_r8(pb);
>  taglen--; /* account for encoding type byte */
> 
> -if (decode_str(s, pb, encoding, , ) < 0) {
> -av_log(s, AV_LOG_ERROR, "Error reading frame %s, skipped\n",
> key);
> -return;
> -}
> -
> -if (!(strcmp(key, "TCON") && strcmp(key, "TCO"))
> &&
> -(sscanf(dst, "(%d)", ) == 1 || sscanf(dst, "%d",
> ) == 1) &&
> -genre <= ID3v1_GENRE_MAX) {
> -av_freep();
> -dst = av_strdup(ff_id3v1_genre_str[genre]);
> -} else if (!(strcmp(key, "TXXX") && strcmp(key, "TXX"))) {
> -/* dst now contains the key, need to get value */
> -key = dst;
> +while (taglen > 1) {

int n = 0;

>  if (decode_str(s, pb, encoding, , ) < 0) {
>  av_log(s, AV_LOG_ERROR, "Error reading frame %s,
> skipped\n", key);
> -av_freep();
>  return;
>  }
> -dict_flags |= AV_DICT_DONT_STRDUP_KEY;
> -} else if (!*dst)
> -av_freep();
> 
> -if (dst)
> -av_dict_set(metadata, key, dst, dict_flags);
> +count++;
> +
> +if (!(strcmp(key, "TCON") && strcmp(key, "TCO"))
> &&
> +(sscanf(dst, "(%d)", ) == 1 || sscanf(dst, "%d",
> ) == 1) &&

(sscanf(dst, "(%d)", ) == 1 || (sscanf(dst, "%d%n", , ) == 1 && n 
== strlen(dst))) &&

avoids parsing genre strings starting with numbers (like '2step')
as genre id.


Thanks for resubmitting,
softworkz

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/3] avisynth: use AviSynth+'s frame properties to set various fields

2022-08-24 Thread Stephen Hutchinson

On 8/24/22 1:04 PM, Steinar Apalnes wrote:

tir. 8. feb. 2022 kl. 12:03 skrev Stephen Hutchinson :


* Field Order
* Chroma Location
* Color Transfer Characteristics
* Color Range
* Color Primaries
* Matrix Coefficients

The existing TFF/BFF detection is retained as a fallback for
older versions of AviSynth that can't access frame properties.
The other properties have no legacy equivalent to detect them.

Signed-off-by: Stephen Hutchinson 


...
  Hi Stephen,

Would it be possible to add support for "_SARum" and "_SARDen" so that
ffmpeg could also recognize the sample aspect ratio in avs scripts?



I'm a bit hesitant to do so, namely because the _SARNum/Den properties
are much more likely to need to have been changed due to operations
in-script, and unless the user is studious about updating those
properties after even just a basic resizing operation, then _SARNum/Den
will still be set to the original values populated by the source filter,
and will be wrong, leading to encodes ending up wrong and potentially
bug reports to Trac which aren't actually the fault of the demuxer.

This is partially coming from the fact that even the color-based
properties that were already added have experienced some level of
backlash because of the requirement for users to ensure the properties
are correctly updated if they've done any changes to those factors
(as best as I'm aware, the filters in the AviSynth+ core still only pass
through the existing properties, but they don't update them if they
pertain to that property's functionality; I believe some external
filters do update them, however).  I would be fairly confident in
betting that users resizing video is far more common than them doing
color correction ops that would require updating the frameprops FFmpeg
can currently read.

One mitigation to that, IMO, would be to flag that as an experimental
feature, making it to where FFmpeg won't read _SARNum/Den unless
the -strict option has been used.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avcodec/libaomenc: remove one memcpy when queueing packets

2022-08-24 Thread James Almer
Don't use an intermediary buffer. Achieve this by replacing FrameListData with
a PacketList, and by allocating and populating every packet's payload before
inserting them into the list.

Signed-off-by: James Almer 
---
 libavcodec/libaomenc.c | 195 +++--
 1 file changed, 70 insertions(+), 125 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 485f554165..f9476b3ddf 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -38,6 +38,7 @@
 
 #include "av1.h"
 #include "avcodec.h"
+#include "bytestream.h"
 #include "bsf.h"
 #include "codec_internal.h"
 #include "encode.h"
@@ -46,24 +47,6 @@
 #include "packet_internal.h"
 #include "profiles.h"
 
-/*
- * Portion of struct aom_codec_cx_pkt from aom_encoder.h.
- * One encoded frame returned from the library.
- */
-struct FrameListData {
-void *buf;   /**< compressed data buffer */
-size_t sz;   /**< length of compressed data */
-int64_t pts; /**< time stamp to show frame
-  (in timebase units) */
-unsigned long duration;  /**< duration to show frame
-  (in timebase units) */
-uint32_t flags;  /**< flags for this frame */
-uint64_t sse[4];
-int have_sse;/**< true if we have pending sse[] */
-uint64_t frame_number;
-struct FrameListData *next;
-};
-
 typedef struct AOMEncoderContext {
 AVClass *class;
 AVBSFContext *bsf;
@@ -71,7 +54,8 @@ typedef struct AOMEncoderContext {
 struct aom_image rawimg;
 struct aom_fixed_buf twopass_stats;
 unsigned twopass_stats_size;
-struct FrameListData *coded_frame_list;
+PacketList coded_frame_list;
+AVPacket *pkt;
 int cpu_used;
 int auto_alt_ref;
 int arnr_max_frames;
@@ -283,33 +267,6 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
 av_log(avctx, level, "\n");
 }
 
-static void coded_frame_add(void *list, struct FrameListData *cx_frame)
-{
-struct FrameListData **p = list;
-
-while (*p)
-p = &(*p)->next;
-*p = cx_frame;
-cx_frame->next = NULL;
-}
-
-static av_cold void free_coded_frame(struct FrameListData *cx_frame)
-{
-av_freep(_frame->buf);
-av_freep(_frame);
-}
-
-static av_cold void free_frame_list(struct FrameListData *list)
-{
-struct FrameListData *p = list;
-
-while (p) {
-list = list->next;
-free_coded_frame(p);
-p = list;
-}
-}
-
 static av_cold int codecctl_int(AVCodecContext *avctx,
 #ifdef UENUM1BYTE
 aome_enc_control_id id,
@@ -432,7 +389,8 @@ static av_cold int aom_free(AVCodecContext *avctx)
 aom_codec_destroy(>encoder);
 av_freep(>twopass_stats.buf);
 av_freep(>stats_out);
-free_frame_list(ctx->coded_frame_list);
+avpriv_packet_list_free(>coded_frame_list);
+av_packet_free(>pkt);
 av_bsf_free(>bsf);
 return 0;
 }
@@ -1042,6 +1000,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
return ret;
 }
 
+ctx->pkt = av_packet_alloc();
+if (!ctx->pkt)
+return AVERROR(ENOMEM);
+
 if (enccfg.rc_end_usage == AOM_CBR ||
 enccfg.g_pass != AOM_RC_ONE_PASS) {
 cpb_props->max_bitrate = avctx->rc_max_rate;
@@ -1053,25 +1015,40 @@ static av_cold int aom_init(AVCodecContext *avctx,
 return 0;
 }
 
-static inline void cx_pktcpy(AOMContext *ctx,
- struct FrameListData *dst,
+static inline int cx_pktcpy(AVCodecContext *avctx,
+ AVPacket *dst,
  const struct aom_codec_cx_pkt *src)
 {
-dst->pts  = src->data.frame.pts;
-dst->duration = src->data.frame.duration;
-dst->flags= src->data.frame.flags;
-dst->sz   = src->data.frame.sz;
-dst->buf  = src->data.frame.buf;
+AOMContext *ctx = avctx->priv_data;
+int av_unused pict_type;
+int ret;
+
+av_packet_unref(dst);
+ret = ff_get_encode_buffer(avctx, dst, src->data.frame.sz, 0);
+if (ret < 0) {
+av_log(avctx, AV_LOG_ERROR,
+   "Error getting output packet of size %"SIZE_SPECIFIER".\n", 
src->data.frame.sz);
+return ret;
+}
+memcpy(dst->data, src->data.frame.buf, src->data.frame.sz);
+dst->pts = dst->dts = src->data.frame.pts;
+
+if (src->data.frame.flags & AOM_FRAME_IS_KEY) {
+dst->flags |= AV_PKT_FLAG_KEY;
 #ifdef AOM_FRAME_IS_INTRAONLY
-dst->frame_number = ++ctx->frame_number;
-dst->have_sse = ctx->have_sse;
+pict_type = AV_PICTURE_TYPE_I;
+} else if (src->data.frame.flags & AOM_FRAME_IS_INTRAONLY) {
+pict_type = AV_PICTURE_TYPE_I;
+} else {
+pict_type = AV_PICTURE_TYPE_P;
+}
+
 if (ctx->have_sse) {
-/* associate last-seen SSE to the frame. */
-/* Transfers ownership from ctx to dst. */
-

Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022

2022-08-24 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Jean-Baptiste Kempf
> Sent: Monday, August 22, 2022 4:39 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v5 00/25] Subtitle Filtering 2022
> 
> On Mon, 22 Aug 2022, at 14:18, Anton Khirnov wrote:
> > Almost exactly identical objections to the basic aspects of the API
> were
> > raised independently by me, Lynne, and Hendrik.
> > IIUC Soft Works still refuses to address them (though it's not so
> easy
> > to tell in a 200-email thread).
> 
> OK. I lost the lists of objections, then.
> 
> --
> Jean-Baptiste Kempf -  President


Could everybody who still has any objection PLEASE name it with reasoning
and explain in which way it should be resolved?


> On Mon, 22 Aug 2022, at 14:18, Anton Khirnov wrote:
...
> (though it's not so easy to tell in a 200-email thread)

Yes that's true. For that reason it is not helpful to talk about
unspecified objections from more than half a year ago.

This is not further actionable without having a list of specific objections.
When nobody responds, we need to assume that there aren't any left.

Thanks,
softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] ipfsgateway: Remove default gateway

2022-08-24 Thread Kieran Kunhya
>
> for libxml2 these problems are less likely to hit us as we likely never
> need a
> "new xml feature" but for a (de)muxer we quite likely will need the
> latests version on every platform.
> Also we have regression tests, external libs make that impossible
> as the version of external libs can change the behavior. Again this
> is a issue for mxf maybe less so libxml. You can also see that we have no
> tests involving  any of the external encoder libs, for that very reason.
> With each external lib that is needed for core features this would
> become a quickly growing problem
>
>

Going back to technical arguments instead of utopian pipedreams (replacing
YouTube and Tiktok lol). You will never fit all the features of complex
containers like MXF, MP4, TS (and for argument's sake XML) inside a
generalised framework like FFmpeg.

Likewise with dav1d, we have seen that an external lib has allowed them to
introduced new paradigms such as mixed frame and sliced threads without
having to redo the whole framework of dozens of codecs. There is value to
this. There are also a lot of modern codec features which aren't easily
fittable into FFmpeg such as dependent substreams.

Kieran


Sent from my mobile device
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] ipfsgateway: Remove default gateway

2022-08-24 Thread Michael Niedermayer
On Wed, Aug 24, 2022 at 06:35:04PM +0200, Tomas Härdin wrote:
[...]
>
> This goes especially for formats like MXF, which I have made the case
> on here multiple times that we should not maintain our own decoder for,
> but rather pull in bmx. And everytime I have suggested this it has been
> made clear that such patches would be rejected. And so MXF developer
> effort is split.

Is there a need for mxf (de) muxing without other containers ?
If the awnser is (mostly) no then the problem is not FFmpeg wanting its
own but rather that someone maintains mxf code outside ffmpeg.


>
> Code is a liability. We should seek to have as little of it as
> possible.

Look back at tesla, "vertical integration is a liability", that sounds
wrong. Quite the opposit, companies that split everything out seem to do
significantly worse. It doesnt mean everything should be done internally
but simply because some external work exists doesnt mean we need to use it
and then have to maybe maintain a codebase that we do not know and that
noone is willing to maintain and that noone from FFmpeg even has write
access to. Next some platforms may carry old versions of that external
code, some might not carry it at all. It can become a mess when we need
a specific feature and when distros like debian hava a policy that requires
shared libs to be used when avaiable. So debian would remove a internal
copy of a lib and force their shared lib to be used. At least that was
the policy when i last looked years ago.
And if we had a internal copy we would also have to do full security
maintaince of that internal copy. Again that is code noone in FFmpeg
knows.

for libxml2 these problems are less likely to hit us as we likely never need a
"new xml feature" but for a (de)muxer we quite likely will need the
latests version on every platform.
Also we have regression tests, external libs make that impossible
as the version of external libs can change the behavior. Again this
is a issue for mxf maybe less so libxml. You can also see that we have no
tests involving  any of the external encoder libs, for that very reason.
With each external lib that is needed for core features this would
become a quickly growing problem

thx

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] ipfsgateway: Remove default gateway

2022-08-24 Thread Michael Niedermayer
On Wed, Aug 24, 2022 at 06:35:04PM +0200, Tomas Härdin wrote:
> mån 2022-08-22 klockan 14:52 +0200 skrev Nicolas George:
> > Tomas Härdin (12022-08-22):
> > > I'd actually argue that in that case we should link a library that
> > > implements IPFS, not split developer effort by trying to implement
> > > it
> > > ourselves.
> > 
> > Is FFmpeg meant to be just a convenient set of wrappers for existing
> > libraries, then?
> 
> It Depends.
> 
> If we could rid this project of all NIH:isms that would be great. Only
> keep that which is strictly better than other existing libraries, for
> example higher-performance decoders. For everything else we can do
> subtree merges if people still insist the project should build "out of
> the box".
> 

> One excellent example of this is the recent discussion around libxml2.
> I maintain that developer effort should go toward improving libxml2.
> Only if that is a lost cause, if libxml2 is hopelessly slow or
> irredeemably buggy, only then would a new XML parser be justified. It
> seems most developers understand this. 

> But for some reason the notion
> that the same applies to *all* parsers, including decoders and
> demuxers, this notion is hard to swallow. And similarly for encoders
> and muxers. I have yet to see a justification that is anything but
> cargo culting.

Its not hard to swallow, it simply is wrong.
Why is there Tesla ?
to build cars ?
no
"Tesla’s mission is to accelerate the world’s transition to sustainable energy."
they could outsource everything, from chip design to batteries to software to
the car seats and so on but they dont because its better to reach their goal
to do them internally

Replace Tesla by FFmpeg, now what is our goal ?
Create some free multimedia framework ?
I would say that is ultimately, wrong
What we had done is to realize peoples multimedia needs and dreams.
People wanted to watch all the propriatary formats on free platforms
Now today you can play any multimedia file with FFmpeg on any free platform

Other things that fit into that mission would be
implement a streaming tool and infrastructure to replace youtube & tiktok
Its multimedia and its something people want, no advertisements, no 
"advertisers first"

Censorship resistant and private multimedia communication is another
potential goal. Just a few days ago i read about some guy who got
all his accounts terminated because his wife sent a picture from their
son to their doctor using his phone. The police was then lookin through
the guys pictures without his knowledge and determined its all fine but
the police couldnt even contanct him because his phone number and all
was terminated. This is not how communication should work, i mean
if you send a picture from your son to your doctor NOONE should be able
to look at that except your doctor. Not apple, not the police not the
government

These are ideas, they need people to work on them, 
iam just saying that IMNSHO these would belong into FFmpegs mission.
now do we need a internal mxf demuxer and muxer for these ? It depends
whatever is more efficient in reaching our goals.
Personally i think internal mxf code is better but i could be wrong.

ill send a 2nd mail more specifically about mxf

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Whats the most studid thing your enemy could do ? Blow himself up
Whats the most studid thing you could do ? Give up your rights and
freedom because your enemy blew himself up.



signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 3/3] doc/fftools-common-opts: document log timing flags

2022-08-24 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 doc/fftools-common-opts.texi | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index d9145704d6..eee3b6ead0 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -201,6 +201,10 @@ and the "Last message repeated n times" line will be 
omitted.
 Indicates that log output should add a @code{[level]} prefix to each message
 line. This can be used as an alternative to log coloring, e.g. when dumping the
 log to file.
+@item timing
+Indicates that log lines should be prefixed with timing information.
+@item datetiming
+Indicates that log lines should be prefixed with date and timing information.
 @end table
 Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single
 flag without affecting other @var{flags} or changing @var{loglevel}. When
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/3] fftools/opt_common: add timing and datetiming log flags

2022-08-24 Thread softworkz
From: softworkz 

This commit adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

Signed-off-by: softworkz 
---
 fftools/opt_common.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index ae5e28a5af..bd8430751c 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -1268,6 +1268,18 @@ int opt_loglevel(void *optctx, const char *opt, const 
char *arg)
 } else {
 flags |= AV_LOG_PRINT_LEVEL;
 }
+} else if (av_strstart(token, "timing", )) {
+if (cmd == '-') {
+flags &= ~AV_LOG_PRINT_TIME;
+} else {
+flags |= AV_LOG_PRINT_TIME;
+}
+} else if (av_strstart(token, "datetiming", )) {
+if (cmd == '-') {
+flags &= ~AV_LOG_PRINT_DATETIME;
+} else {
+flags |= AV_LOG_PRINT_DATETIME;
+}
 } else {
 break;
 }
-- 
ffmpeg-codebot

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/3] avutil/log: support logging of date and timing information

2022-08-24 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 doc/APIchanges  |  3 +++
 libavutil/log.c | 32 +---
 libavutil/log.h | 10 ++
 libavutil/version.h |  4 ++--
 4 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4c0c9db628..eae5ba0525 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil: 2021-04-27
 
 API changes, most recent first:
 
+2022-08-xx - xx - lavu 57.34.100 - log.h
+  Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME.
+
 2022-08-xx - xx - lavf 59 - avformat.h
   Deprecate av_stream_get_end_pts() without replacement.
 
diff --git a/libavutil/log.c b/libavutil/log.c
index 5948e50467..15a43c1631 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -42,6 +42,8 @@
 #include "internal.h"
 #include "log.h"
 #include "thread.h"
+#include "time.h"
+#include "time_internal.h"
 
 static AVMutex mutex = AV_MUTEX_INITIALIZER;
 
@@ -291,14 +293,32 @@ static const char *get_level_str(int level)
 }
 }
 
+static void format_date_now(AVBPrint* timeBuf, int include_date)
+{
+struct tm *ptm, tmbuf;
+const int64_t time_us = av_gettime();
+const int64_t time_ms = time_us / 1000;
+const time_t time_s   = time_ms / 1000;
+const int millisec= time_ms - (time_s * 1000);
+ptm   = localtime_r(_s, );
+if (ptm) {
+if (include_date)
+av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm);
+
+av_bprint_strftime(timeBuf, "%H:%M:%S", ptm);
+av_bprintf(timeBuf, ".%03d ", millisec);
+}
+}
+
 static void format_line(void *avcl, int level, const char *fmt, va_list vl,
-AVBPrint part[4], int *print_prefix, int type[2])
+AVBPrint part[5], int *print_prefix, int type[2])
 {
 AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
 av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprint_init(part+3, 0, 65536);
+av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC);
 
 if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
 if (*print_prefix && avc) {
@@ -316,6 +336,9 @@ static void format_line(void *avcl, int level, const char 
*fmt, va_list vl,
 if(type) type[1] = get_category(avcl);
 }
 
+if (*print_prefix && (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME)))
+format_date_now([4], flags & AV_LOG_PRINT_DATETIME);
+
 if (*print_prefix && (level > AV_LOG_QUIET) && (flags & 
AV_LOG_PRINT_LEVEL))
 av_bprintf(part+2, "[%s] ", get_level_str(level));
 
@@ -336,7 +359,7 @@ void av_log_format_line(void *ptr, int level, const char 
*fmt, va_list vl,
 int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
 char *line, int line_size, int *print_prefix)
 {
-AVBPrint part[4];
+AVBPrint part[5];
 int ret;
 
 format_line(ptr, level, fmt, vl, part, print_prefix, NULL);
@@ -350,7 +373,7 @@ void av_log_default_callback(void* ptr, int level, const 
char* fmt, va_list vl)
 static int print_prefix = 1;
 static int count;
 static char prev[LINE_SZ];
-AVBPrint part[4];
+AVBPrint part[5];
 char line[LINE_SZ];
 static int is_atty;
 int type[2];
@@ -385,6 +408,9 @@ void av_log_default_callback(void* ptr, int level, const 
char* fmt, va_list vl)
 count = 0;
 }
 strcpy(prev, line);
+
+sanitize(part[4].str);
+colored_fputs(7, 0, part[4].str);
 sanitize(part[0].str);
 colored_fputs(type[0], 0, part[0].str);
 sanitize(part[1].str);
diff --git a/libavutil/log.h b/libavutil/log.h
index ab7ceabe22..8336f65b16 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char 
*fmt, va_list vl,
  */
 #define AV_LOG_PRINT_LEVEL 2
 
+/**
+ * Include system time in log output.
+ */
+#define AV_LOG_PRINT_TIME 4
+
+/**
+ * Include system date and time in log output.
+ */
+#define AV_LOG_PRINT_DATETIME 8
+
 void av_log_set_flags(int arg);
 int av_log_get_flags(void);
 
diff --git a/libavutil/version.h b/libavutil/version.h
index 05661922b3..5d0df781cc 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#define LIBAVUTIL_VERSION_MINOR  33
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  34
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
ffmpeg-codebot

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 0/3] Add option to log timing

2022-08-24 Thread ffmpegagent
This pathcset adds two logging flags: 'timing' and 'datetiming'.

Usage:

ffmpeg -loglevel +timing

or

ffmpeg -loglevel +datetiming

softworkz (3):
  avutil/log: support logging of date and timing information
  fftools/opt_common: add timing and datetiming log flags
  doc/fftools-common-opts: document log timing flags

 doc/APIchanges   |  3 +++
 doc/fftools-common-opts.texi |  4 
 fftools/opt_common.c | 12 
 libavutil/log.c  | 32 +---
 libavutil/log.h  | 10 ++
 libavutil/version.h  |  4 ++--
 6 files changed, 60 insertions(+), 5 deletions(-)


base-commit: 48cb2c7a8a2deca40dd2f143848dd5addc25465c
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-37%2Fsoftworkz%2Fsubmit_logtiming-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-37/softworkz/submit_logtiming-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/37
-- 
ffmpeg-codebot
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] API documentation

2022-08-24 Thread Michael Niedermayer
Hi

On Wed, Aug 24, 2022 at 03:15:45PM +0200, Michael Riedl wrote:
> Hi,
> 
> I saw on the FFmpeg website that for some stable versions there is no
> API documentation. The latest stable documentation (for version 4.1) is
> four years old.
> 
> We managed to build the API documentation for 5.1
> (https://ffmpeg-docs.tools.nativewaves.com/5.1/index.html) and other
> stable versions (https://ffmpeg-docs.tools.nativewaves.com/). We happily
> offer to host the documentation (updated regularly) free of charge.
> Maybe our page can be linked on FFmpeg's documentation page
> (https://ffmpeg.org/documentation.html) to complete it with respect to
> recent releases.
> 
> Please let me know what you think.

Fixed the doxy documentation on ffmpeg.org.
For git master it was and is automatically generated but for releases it was
and is manual.
I forgot generating it after 4.1 it seems, it wasnt in my list of things to
do for release for some reason

thx


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libaomenc: use av_fast_realloc() to resize the stats buffer

2022-08-24 Thread James Zern
On Tue, Aug 23, 2022 at 4:34 PM James Almer  wrote:
>
> Signed-off-by: James Almer 
> ---
>  libavcodec/libaomenc.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
>

lgtm.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/libvpxenc: use av_fast_realloc() to resize the stats buffer

2022-08-24 Thread James Zern
On Tue, Aug 23, 2022 at 4:34 PM James Almer  wrote:
>
> Signed-off-by: James Almer 
> ---
>  libavcodec/libvpxenc.c | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
>

lgtm.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 2/3] avisynth: use AviSynth+'s frame properties to set various fields

2022-08-24 Thread Steinar Apalnes
tir. 8. feb. 2022 kl. 12:03 skrev Stephen Hutchinson :

> * Field Order
> * Chroma Location
> * Color Transfer Characteristics
> * Color Range
> * Color Primaries
> * Matrix Coefficients
>
> The existing TFF/BFF detection is retained as a fallback for
> older versions of AviSynth that can't access frame properties.
> The other properties have no legacy equivalent to detect them.
>
> Signed-off-by: Stephen Hutchinson 
>
...
 Hi Stephen,

Would it be possible to add support for "_SARum" and "_SARDen" so that
ffmpeg could also recognize the sample aspect ratio in avs scripts?

-steinar
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] ipfsgateway: Remove default gateway

2022-08-24 Thread Tomas Härdin
mån 2022-08-22 klockan 14:52 +0200 skrev Nicolas George:
> Tomas Härdin (12022-08-22):
> > I'd actually argue that in that case we should link a library that
> > implements IPFS, not split developer effort by trying to implement
> > it
> > ourselves.
> 
> Is FFmpeg meant to be just a convenient set of wrappers for existing
> libraries, then?

It Depends.

If we could rid this project of all NIH:isms that would be great. Only
keep that which is strictly better than other existing libraries, for
example higher-performance decoders. For everything else we can do
subtree merges if people still insist the project should build "out of
the box".

One excellent example of this is the recent discussion around libxml2.
I maintain that developer effort should go toward improving libxml2.
Only if that is a lost cause, if libxml2 is hopelessly slow or
irredeemably buggy, only then would a new XML parser be justified. It
seems most developers understand this. But for some reason the notion
that the same applies to *all* parsers, including decoders and
demuxers, this notion is hard to swallow. And similarly for encoders
and muxers. I have yet to see a justification that is anything but
cargo culting.

This goes especially for formats like MXF, which I have made the case
on here multiple times that we should not maintain our own decoder for,
but rather pull in bmx. And everytime I have suggested this it has been
made clear that such patches would be rejected. And so MXF developer
effort is split.

Code is a liability. We should seek to have as little of it as
possible.

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 03/18] lavf/dv: always provide avpriv_dv_* symbols

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> They are used from libavdevice.
> ---
>  configure|  1 +
>  libavformat/Makefile |  3 +--
>  libavformat/dv.c | 23 +++
>  3 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index ea50c94002..f4c4ab0484 100755
> --- a/configure
> +++ b/configure
> @@ -3530,6 +3530,7 @@ gdigrab_indev_deps="CreateDIBSection"
>  gdigrab_indev_extralibs="-lgdi32"
>  gdigrab_indev_select="bmp_decoder"
>  iec61883_indev_deps="libiec61883"
> +iec61883_indev_select="dv_demuxer"
>  jack_indev_deps="libjack"
>  jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
>  kmsgrab_indev_deps="libdrm"
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index f67a99f839..684bad0eb4 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -13,6 +13,7 @@ OBJS = allformats.o \
> demux.o  \
> demux_utils.o\
> dump.o   \
> +   dv.o \
> format.o \
> id3v1.o  \
> id3v2.o  \
> @@ -184,7 +185,6 @@ OBJS-$(CONFIG_DSS_DEMUXER)   += dss.o
>  OBJS-$(CONFIG_DTSHD_DEMUXER) += dtshddec.o
>  OBJS-$(CONFIG_DTS_DEMUXER)   += dtsdec.o rawdec.o
>  OBJS-$(CONFIG_DTS_MUXER) += rawenc.o
> -OBJS-$(CONFIG_DV_DEMUXER)+= dv.o
>  OBJS-$(CONFIG_DV_MUXER)  += dvenc.o
>  OBJS-$(CONFIG_DVBSUB_DEMUXER)+= dvbsub.o rawdec.o
>  OBJS-$(CONFIG_DVBTXT_DEMUXER)+= dvbtxt.o rawdec.o
> @@ -711,7 +711,6 @@ SHLIBOBJS-$(CONFIG_RTP_MUXER)+= golomb_tab.o 
> jpegtables.o \
>  SHLIBOBJS-$(CONFIG_SPDIF_MUXER)  += dca_sample_rate_tab.o
>  
>  # libavdevice dependencies
> -OBJS-$(CONFIG_IEC61883_INDEV)+= dv.o
>  
>  # Windows resource file
>  SHLIBOBJS-$(HAVE_GNU_WINDRES)+= avformatres.o
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 1dadaf6e62..24bacd5c53 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -28,6 +28,9 @@
>   * License along with FFmpeg; if not, write to the Free Software
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
> +
> +#include "config_components.h"
> +
>  #include 
>  #include "avformat.h"
>  #include "internal.h"
> @@ -40,6 +43,8 @@
>  #include "dv.h"
>  #include "libavutil/avassert.h"
>  
> +#if CONFIG_DV_DEMUXER
> +
>  // Must be kept in sync with AVPacket
>  struct DVPacket {
>  int64_t  pts;
> @@ -647,3 +652,21 @@ const AVInputFormat ff_dv_demuxer = {
>  .read_seek  = dv_read_seek,
>  .extensions = "dv,dif",
>  };
> +
> +#else // CONFIG_DV_DEMUXER
> +DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
> +{
> +return NULL;
> +}
> +
> +int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt)
> +{
> +return AVERROR(ENOSYS);
> +}
> +
> +int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
> + uint8_t *buf, int buf_size, int64_t pos)
> +{
> +return AVERROR(ENOSYS);
> +}
> +#endif // CONFIG_DV_DEMUXER

This is unnecessary as the Makefile above ensures that dv.o is built
when iec61883 is built.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avcodec/gif: fix duration of last packet/frame

2022-08-24 Thread Paul B Mahol
On Wed, Aug 24, 2022 at 6:15 PM Tomas Härdin  wrote:

> tis 2022-08-23 klockan 14:18 +0200 skrev Andreas Rheinhardt:
> > Paul B Mahol:
> > > Hi,
> > >
> > > patch attached.
> > >
> > >  return ret;
> > >  }
> > >
> > > +pkt->duration = av_rescale_q(pict->duration, (AVRational){ 1,
> > > 100 },
> > > + avctx->time_base);
> > >  pkt->size   = outbuf_ptr - pkt->data;
> > >  if (s->image || !avctx->frame_number)
> > >  pkt->flags |= AV_PKT_FLAG_KEY;
> >
> > Where does the magic 1/100 timebase come from?
>
> From the spec
>

This patch need frame duration handling in libavfilter that is currently
WIP.


>
> /Tomas
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] avcodec/gif: fix duration of last packet/frame

2022-08-24 Thread Tomas Härdin
tis 2022-08-23 klockan 14:18 +0200 skrev Andreas Rheinhardt:
> Paul B Mahol:
> > Hi,
> > 
> > patch attached.
> > 
> >  return ret;
> >  }
> >  
> > +    pkt->duration = av_rescale_q(pict->duration, (AVRational){ 1,
> > 100 },
> > + avctx->time_base);
> >  pkt->size   = outbuf_ptr - pkt->data;
> >  if (s->image || !avctx->frame_number)
> >  pkt->flags |= AV_PKT_FLAG_KEY;
> 
> Where does the magic 1/100 timebase come from?

From the spec

/Tomas

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 12/18] lavf/dv: make returning the video packet optional

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> The mov demuxer only returns DV audio, video packets are discarded.
> 
> It first reads the data to be parsed into a packet. Then both this
> packet and the pointer to its data are passed together to
> avpriv_dv_produce_packet(), which parses the data and partially
> overwrites the packet. This is confusing and potentially dangerous, so
> just pass NULL and avoid pointless packet modification.
> ---
>  libavformat/dv.c  | 19 +++
>  libavformat/mov.c |  2 +-
>  2 files changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 303cecf9bb..f88fe62349 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -430,14 +430,17 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, 
> AVPacket *pkt,
>  }
>  }
>  
> -/* Now it's time to return video packet */
> -size = dv_extract_video_info(c, buf);
> -pkt->data = buf;
> -pkt->pos  = pos;
> -pkt->size = size;
> -pkt->flags   |= AV_PKT_FLAG_KEY;
> -pkt->stream_index = c->vst->index;
> -pkt->pts  = c->frames;
> +/* return the video packet, if the caller wants it */
> +if (pkt) {
> +size = dv_extract_video_info(c, buf);
> +
> +pkt->data = buf;
> +pkt->pos  = pos;
> +pkt->size = size;
> +pkt->flags   |= AV_PKT_FLAG_KEY;
> +pkt->stream_index = c->vst->index;
> +pkt->pts  = c->frames;
> +}
>  
>  c->frames++;
>  
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 1d8c5b2904..a2b429e52f 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -8768,7 +8768,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
> *pkt)
>  }
>  #if CONFIG_DV_DEMUXER
>  if (mov->dv_demux && sc->dv_audio_container) {
> -ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, 
> pkt->size, pkt->pos);
> +ret = avpriv_dv_produce_packet(mov->dv_demux, NULL, pkt->data, 
> pkt->size, pkt->pos);
>  av_packet_unref(pkt);
>  if (ret < 0)
>  return ret;

1. LGTM.
2. The way mov handles dv audio is very broken:
a) I don't see anything that guarantees that the
samplerate of the inner demuxer and the sample rate reported to the user
(presumably taken from mov structures) coincide.
b) dv_fctx and dv_demux are part of MOVContext, not MOVStreamContext. If
there were multiple MOVStreams with dv-audio, the older dv_fctx and
dv_demux would leak. Do you see anything that guarantees that they will
 only be at most one MOVStream for dv-audio?
c) The former would be easily fixable by moving the fields to
MOVStreamContext. But there is actually another bug: The underlying dv
stream can contain multiple audio streams in this one MOVStream and only
the first of these is forwarded.
https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2
contains a sample where this actually occurs: The DV stream has two
stereo tracks, only the first of which is forwarded (use -enable_drefs 1
to be able to play it; the non-forwarded seems to be silent in this
case). Are these actually independent audios or are these stereo pairs
part of a single streams with more than two channels?

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-08-24 Thread Nicolas George
Andreas Rheinhardt (12022-08-24):
> Where is this header?

# Note: FF_NEW_SZ is a macro defined elsewhere; it is really part of the
# implementation more than the API.

This is all there is to it for this case. I can move it here for now.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-08-24 Thread Andreas Rheinhardt
Nicolas George:
> The actual implementation, tests and uses in the rest of
> FFmpeg code will be committed separately once the API is
> settled.
> 

I think you misunderstood JB: He did not say that the headers are pushed
without the implementation, he just said that the headers should be
discussed and approved before you code the actual implementation:

> 
> You provide a full header and documentation, and then get it discussed.
> When there is a consensus for approval of the headers, then, you can code the 
> core of it that matches the headers.
> That avoids the "I spent time for nothing" issue.

> diff --git a/libavutil/writer.h b/libavutil/writer.h
> new file mode 100644
> index 00..55e2cf3ea6
> --- /dev/null
> +++ b/libavutil/writer.h
> @@ -0,0 +1,484 @@
> +/*
> + * Copyright (c) 2022 The FFmpeg project
> + *
> + * 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 AVUTIL_WRITER_H
> +#define AVUTIL_WRITER_H
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "extendable.h"

Where is this header?

> +#include "bprint.h"
> +
> +/**
> + * @defgroup av_writer AVWriter
> + *
> + * Object-oriented API to write strings and binary data.
> + *
> + * @{
> + */
> +
> +typedef struct AVWriterMethods AVWriterMethods;
> +
> +/**
> + * Opaque object to write strings and binary data.
> + *
> + * AVWriter is meant to allow to build and return strings (and blocks of
> + * binary data) efficiently between functions.
> + * For example, a function that serialize something into a string will
> + * actually write into an AVWriter, and the caller will choose the way the
> + * data will be stored or processed on the fly.
> + *
> + * For a quick introduction on how to use AVWriter in simple cases, see
> + * doc/avwriter_intro.md.
> + *
> + * There are various pre-defined types of AVWriter, see below:
> + *
> + * - av_dynbuf_writer() writes the data into a buffer that is grown with
> + *   av_realloc() if it does not fit in the initial buffer; it is the
> + *   recommended choice.
> + *
> + * - av_buf_writer() writes the data into a pre-existing finite buffer.
> + *
> + * - av_stdio_writer() writes the data into a FILE*.
> + *
> + * - av_log_writer() writes the data to av_log().
> + *
> + * AVWriter objects are passed by value. It allows creating a writer on the
> + * fly, without extra variable or error checking. The structure can never
> + * change.
> + */
> +typedef struct AVWriter {
> +const AVWriterMethods *methods;
> +void *obj;
> +} AVWriter;
> +
> +/**
> + * Write a data buffer to an AVWriter.
> + */
> +void av_writer_write(AVWriter wr, const char *buf, size_t size);
> +
> +/**
> + * Write a 0-terminated string to an AVWriter.
> + */
> +void av_writer_print(AVWriter wr, const char *str);
> +
> +/**
> + * Write a formatted string to an AVWriter.
> + * Note: do not use libc-specific extensions to the format string.
> + */
> +void av_writer_printf(AVWriter wr, const char *fmt, ...);
> +
> +/**
> + * Write a formatted to string an AVWriter using a va_list.

s/to string/string to/

> + */
> +void av_writer_vprintf(AVWriter wr, const char *fmt, va_list va);

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-08-24 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Nicolas George
> Sent: Wednesday, August 24, 2022 5:18 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] lavu: header and documentation for
> AVWriter
> 
> The actual implementation, tests and uses in the rest of
> FFmpeg code will be committed separately once the API is
> settled.
> 
> Signed-off-by: Nicolas George 
> ---
>  doc/avwriter_intro.md | 109 ++
>  libavutil/writer.h| 484
> ++
>  2 files changed, 593 insertions(+)
>  create mode 100644 doc/avwriter_intro.md
>  create mode 100644 libavutil/writer.h
> 
> 
> As suggested by JB, here is the header and documentation for
> AVWriter,
> to discuss the principle before investing time in polishing the
> implementation. I expect to discuss the API and if no blockign
> objections are raised push it then spend time on the implementation.
> 
> This API is a nicer and much more powerful version of BPrint. It can
> be
> used to simplify existing code where BPrint could help, plus places
> where BPrint could not help.
> 
> It also is the prerequisite for more ambitious projects, expecially
> universal serialization of FFmpeg objects (side data and such) into
> standardized formats.
> 
> The implementation is in most part done, and I am sure I can deliver.
> What remains is the boring part of integrating the tests in FATE,
> polishing various parts, updating the parts where I changed my mind
> midway, etc.
> 
> Note: FF_NEW_SZ is a macro defined elsewhere; it is really part of
> the
> implementation more than the API.
> 
> 
> diff --git a/doc/avwriter_intro.md b/doc/avwriter_intro.md
> new file mode 100644
> index 00..4fd8a5a4ad
> --- /dev/null
> +++ b/doc/avwriter_intro.md
> @@ -0,0 +1,109 @@
> +# Quick start guide for AVWriter
> +
> +AVWriter is an API to unify functions returning strings (or any
> arbitrary
> +binary buffer) and to make building strings from parts easier. Here
> is a
> +quick introduction with pairs of “what I would do without AVWriter”
> /
> +“how to do it with AVWriter” of example code.
> +
> +## I want a `char*` buffer, the function wants an AVWriter
> +
> +Old-style code:
> +
> +```
> +char *buf;
> +ret = av_something_to_string(, something);
> +if (ret < 0)
> +die("Failed");
> +use_string(buf);
> +av_freep();
> +```
> +
> +Equivalent code with AVWriter:
> +
> +```
> +AVWriter wr = av_dynbuf_writer();
> +av_something_write(wr, something, 0);
> +if (av_writer_get_error(wr, 0) < 0)
> +die("Failed");

Will it be possible to do:

av_something_write(wr, something1, 0);
av_something_write(wr, something2, 0);
av_something_write(wr, something3, 0);
if (av_writer_get_error(wr, 0) < 0)
die("Failed");

or would av_writer_get_error() need to be called after each 
av_something_write()?

Thanks,
softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] lavu: header and documentation for AVWriter

2022-08-24 Thread Nicolas George
The actual implementation, tests and uses in the rest of
FFmpeg code will be committed separately once the API is
settled.

Signed-off-by: Nicolas George 
---
 doc/avwriter_intro.md | 109 ++
 libavutil/writer.h| 484 ++
 2 files changed, 593 insertions(+)
 create mode 100644 doc/avwriter_intro.md
 create mode 100644 libavutil/writer.h


As suggested by JB, here is the header and documentation for AVWriter,
to discuss the principle before investing time in polishing the
implementation. I expect to discuss the API and if no blockign
objections are raised push it then spend time on the implementation.

This API is a nicer and much more powerful version of BPrint. It can be
used to simplify existing code where BPrint could help, plus places
where BPrint could not help.

It also is the prerequisite for more ambitious projects, expecially
universal serialization of FFmpeg objects (side data and such) into
standardized formats.

The implementation is in most part done, and I am sure I can deliver.
What remains is the boring part of integrating the tests in FATE,
polishing various parts, updating the parts where I changed my mind
midway, etc.

Note: FF_NEW_SZ is a macro defined elsewhere; it is really part of the
implementation more than the API.


diff --git a/doc/avwriter_intro.md b/doc/avwriter_intro.md
new file mode 100644
index 00..4fd8a5a4ad
--- /dev/null
+++ b/doc/avwriter_intro.md
@@ -0,0 +1,109 @@
+# Quick start guide for AVWriter
+
+AVWriter is an API to unify functions returning strings (or any arbitrary
+binary buffer) and to make building strings from parts easier. Here is a
+quick introduction with pairs of “what I would do without AVWriter” /
+“how to do it with AVWriter” of example code.
+
+## I want a `char*` buffer, the function wants an AVWriter
+
+Old-style code:
+
+```
+char *buf;
+ret = av_something_to_string(, something);
+if (ret < 0)
+die("Failed");
+use_string(buf);
+av_freep();
+```
+
+Equivalent code with AVWriter:
+
+```
+AVWriter wr = av_dynbuf_writer();
+av_something_write(wr, something, 0);
+if (av_writer_get_error(wr, 0) < 0)
+die("Failed");
+use_string(av_dynbuf_writer_get_data(wr, NULL));
+av_dynbuf_writer_finalize(wr, NULL, NULL);
+```
+
+If the string is small enough, no dynamic memory allocation happens.
+
+The NULL to `av_dynbuf_writer_get_data()` can be used to retrieve the size
+of the data in the buffer.
+
+Calling `av_writer_get_error()` is mandatory.
+
+## I want a *persistent* `char*` buffer, the function wants an AVWriter
+
+Old-style code:
+
+```
+char *buf;
+ret = av_something_to_string(, something);
+if (ret < 0)
+die("Failed");
+ctx->string = buf;
+```
+
+Equivalent code with AVWriter:
+
+```
+AVWriter wr = av_dynbuf_writer();
+av_something_write(wr, something, 0);
+ret = av_dynbuf_writer_finalize(wr, >string, NULL);
+if (ret < 0)
+die("Failed");
+```
+
+## I have a `char[]` buffer, the function wants an AVWriter
+
+Old-style code:
+
+```
+char buf[BUF_SIZE];
+av_something_to_string(buf, sizeof(buf), something);
+use_string(buf);
+```
+
+Equivalent code with AVWriter:
+
+```
+char buf[BUF_SIZE];
+av_something_write(av_buf_writer(buf, sizeof(buf)), something, 0);
+use_string(buf);
+```
+
+## I need to build a string from parts
+
+Old-style code:
+
+```
+char buf[1024];
+int pos = 0;
+pos += snprintf(buf + pos, sizeof(buf) - pos,
+"Stream %d: ", i);
+av_get_channel_layout_string(buf + pos, sizeof(buf) - pos,
+ nb, layout);
+pos += strlen(buf + pos);
+pos += snprintf(buf + pos, sizeof(buf) - pos,
+", %s", av_get_sample_fmt_name(fmt));
+```
+
+Note: this code could overflow the buffer.
+
+Equivalent code with AVWriter:
+
+```
+AVWriter wr = av_dynbuf_writer();
+av_writer_printf(wr, "Stream %d: ", i);
+av_channel_layout_write(wr, nb, layout, 0);
+av_writer_printf(wr, ", %s", av_get_sample_fmt_name(fmt));
+```
+
+See the first example on how to access the resulting string.
+
+Note: this is very similar to using AVBPrint; from this side, AVWriter
+replaces AVBPrint.
diff --git a/libavutil/writer.h b/libavutil/writer.h
new file mode 100644
index 00..55e2cf3ea6
--- /dev/null
+++ b/libavutil/writer.h
@@ -0,0 +1,484 @@
+/*
+ * Copyright (c) 2022 The FFmpeg project
+ *
+ * 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 

Re: [FFmpeg-devel] [PATCH 18/18] lavf/dv: do not continuously set stream timebase

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> The code will call avpriv_set_pts_info() for each video frame, possibly
> setting a different timebase if the stream framerate changes. This
> violates API conventions, as the timebase is supposed to stay constant
> after stream creation.
> 
> Change the demuxer to set a single timebase that is granular enough to
> handle all supported DV framerates.
> 
> The seek tests change slightly because the new timebase is more
> granular.
> ---
>  libavformat/dv.c  | 16 
>  tests/ref/seek/lavf-dv| 30 +++---
>  tests/ref/seek/vsynth_lena-dv | 24 
>  tests/ref/seek/vsynth_lena-dv-411 | 24 
>  tests/ref/seek/vsynth_lena-dv-50  | 24 
>  5 files changed, 63 insertions(+), 55 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index ffed1a7a90..e2f7a6d313 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -69,6 +69,8 @@ struct DVDemuxContext {
>  uint8_t   audio_buf[4][8192];
>  int   ach;
>  int   frames;
> +
> +int64_t   next_pts;
>  };
>  
>  static inline uint16_t dv_audio_12to16(uint16_t sample)
> @@ -314,8 +316,6 @@ static int dv_extract_video_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  
>  par = c->vst->codecpar;
>  
> -avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
> -c->sys->time_base.den);
>  c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);

This will now set the avg_frame_rate to 6fps. Obviously wrong.
Anyway, this field should probably not be set for every frame.

>  
>  /* finding out SAR is a little bit messy */
> @@ -360,6 +360,8 @@ static int dv_init_demux(AVFormatContext *s, 
> DVDemuxContext *c)
>  c->vst->codecpar->bit_rate   = 2500;
>  c->vst->start_time= 0;
>  
> +avpriv_set_pts_info(c->vst, 64, 1, 6);
> +
>  /* Audio streams are added later as they are encountered. */
>  s->ctx_flags |= AVFMTCTX_NOHEADER;
>  
> @@ -463,7 +465,10 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
> *pkt,
>  pkt->size = size;
>  pkt->flags   |= AV_PKT_FLAG_KEY;
>  pkt->stream_index = c->vst->index;
> -pkt->pts  = c->frames;
> +pkt->pts  = c->next_pts;
> +pkt->duration = av_rescale_q(1, c->sys->time_base, 
> c->vst->time_base);
> +
> +c->next_pts += pkt->duration;
>  }
>  
>  c->frames++;
> @@ -477,11 +482,12 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
> DVDemuxContext *c,
>  // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is 
> junk)
>  FFFormatContext *const si = ffformatcontext(s);
>  const int frame_size = c->sys->frame_size;
> +int64_t  frame_count = av_rescale_q(timestamp, c->vst->time_base, 
> c->sys->time_base);
>  int64_t offset;
>  int64_t size   = avio_size(s->pb) - si->data_offset;
>  int64_t max_offset = ((size - 1) / frame_size) * frame_size;
>  
> -offset = frame_size * timestamp;
> +offset = frame_size * frame_count;
>  
>  if (size >= 0 && offset > max_offset)
>  offset = max_offset;
> @@ -494,6 +500,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
> DVDemuxContext *c,
>  void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
>  {
>  c->frames = frame_offset;
> +if (c->sys)
> +c->next_pts = av_rescale_q(frame_offset, c->sys->time_base, 
> c->vst->time_base);
>  c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
>  c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
>  }
> diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
> index f63e4460be..356f05546b 100644
> --- a/tests/ref/seek/lavf-dv
> +++ b/tests/ref/seek/lavf-dv
> @@ -3,50 +3,50 @@ ret: 0 st:-1 flags:0  ts:-1.00
>  ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000
>  ret: 0 st:-1 flags:1  ts: 1.894167
>  ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> -ret: 0 st: 0 flags:0  ts: 0.80
> +ret: 0 st: 0 flags:0  ts: 0.788333
>  ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:288 
> size:144000
> -ret: 0 st: 0 flags:1  ts:-0.32
> +ret: 0 st: 0 flags:1  ts:-0.317500
>  ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000
>  ret: 0 st: 1 flags:0  ts: 2.56
> -ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000

This is IMO more than "slightly".

>  ret: 0 st: 1 flags:1  ts: 1.48
> -ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
> size:144000
> +ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
> size:144000
>  ret: 0

Re: [FFmpeg-devel] [PATCH 16/18] lavf/dv: set audio bitrate only at stream creation

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> Demuxers are not supposed to update AVCodecParameters after the stream
> was seen by the caller. This value is not important enough to support
> dynamic updates for.
> ---
>  libavformat/dv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index f65c2d596f..9c8b0a262c 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -280,6 +280,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
>  c->ast[i]->codecpar->ch_layout  = 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>  c->ast[i]->start_time   = 0;
> +c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
>  
>  c->audio_pkt[i].size = 0;
>  c->audio_pkt[i].data = c->audio_buf[i];
> @@ -290,7 +291,6 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->audio_pkt[i].pos  = -1;
>  }
>  c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
> -c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
>  }
>  c->ach = ach;
>  

FYI: dv_extract_video_info() also sets bit_rate (and avg_frame_rate and
sample_aspect_ratio) on every packet.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 17/18] lavf/dv: do not update AVCodecParameters.sample_rate while demuxing

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> Demuxers are not allowed to do this and few callers, if any, will handle
> this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data
> instead.
> ---
>  libavformat/dv.c | 49 +---
>  1 file changed, 34 insertions(+), 15 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 9c8b0a262c..ffed1a7a90 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -33,6 +33,7 @@
>  
>  #include 
>  #include "avformat.h"
> +#include "demux.h"
>  #include "internal.h"
>  #include "libavcodec/dv_profile.h"
>  #include "libavcodec/dv.h"
> @@ -46,7 +47,7 @@
>  #if CONFIG_DV_DEMUXER
>  
>  // Must be kept in sync with AVPacket
> -struct DVPacket {
> +typedef struct DVPacket {
>  int64_t  pts;
>  uint8_t *data;
>  int  size;
> @@ -54,7 +55,10 @@ struct DVPacket {
>  int  flags;
>  int64_t  pos;
>  int64_t  duration;
> -};
> +
> +int sample_rate;
> +int last_sample_rate;
> +} DVPacket;
>  
>  struct DVDemuxContext {
>  const AVDVProfile*  sys;/* Current DV profile. E.g.: 525/60, 625/50 
> */
> @@ -237,7 +241,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
> **ppcm,
>  static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
>  {
>  const uint8_t *as_pack;
> -int freq, stype, smpls, quant, i, ach;
> +int freq, stype, smpls, quant, i, ach, sr;
>  
>  as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE);
>  if (!as_pack || !c->sys) {/* No audio ? */
> @@ -255,6 +259,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
> "Unrecognized audio sample rate index (%d)\n", freq);
>  return 0;
>  }
> +sr = dv_audio_frequency[freq];
>  
>  if (stype > 3) {
>  av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype);
> @@ -280,7 +285,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, 
> const uint8_t *frame)
>  c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
>  c->ast[i]->codecpar->ch_layout  = 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>  c->ast[i]->start_time   = 0;
> -c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
> +c->ast[i]->codecpar->bit_rate   = 2 * sr * 16;
> +
> +c->ast[i]->codecpar->sample_rate = sr;
> +c->audio_pkt[i].last_sample_rate = sr;
>  
>  c->audio_pkt[i].size = 0;
>  c->audio_pkt[i].data = c->audio_buf[i];
> @@ -290,7 +298,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->audio_pkt[i].duration = 0;
>  c->audio_pkt[i].pos  = -1;
>  }
> -c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
> +
> +c->audio_pkt[i].sample_rate = sr;
>  }
>  c->ach = ach;
>  
> @@ -380,16 +389,26 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket 
> *pkt)
>  
>  for (i = 0; i < c->ach; i++) {
>  if (c->ast[i] && c->audio_pkt[i].size) {
> -pkt->size = c->audio_pkt[i].size;
> -pkt->data = c->audio_pkt[i].data;
> -pkt->stream_index = c->audio_pkt[i].stream_index;
> -pkt->flags= c->audio_pkt[i].flags;
> -pkt->pts  = c->audio_pkt[i].pts;
> -pkt->duration = c->audio_pkt[i].duration;
> -pkt->pos  = c->audio_pkt[i].pos;
> -
> -c->audio_pkt[i].size = 0;
> -size = pkt->size;
> +DVPacket *dpkt = >audio_pkt[i];
> +
> +pkt->size = dpkt->size;
> +pkt->data = dpkt->data;
> +pkt->stream_index = dpkt->stream_index;
> +pkt->flags= dpkt->flags;
> +pkt->pts  = dpkt->pts;
> +pkt->duration = dpkt->duration;
> +pkt->pos  = dpkt->pos;
> +
> +dpkt->size = 0;
> +size   = pkt->size;
> +
> +if (dpkt->last_sample_rate != dpkt->sample_rate) {
> +int ret = ff_add_param_change(pkt, 0, 0, dpkt->sample_rate, 
> 0, 0);
> +if (ret < 0)
> +return ret;
> +dpkt->last_sample_rate = dpkt->sample_rate;
> +}
> +
>  break;
>  }
>  }

1. One of the callers which did not handle this correctly is the mov
demuxer: A sample rate update would not propagate to the user, because
it uses a separate AVFormatContext for it. This should be mentioned in
the commit message. (Btw: I don't see anything that guarantees that the
samplerate and timebase of the inner demuxer and the sample rate and
time base reported to the user (presumably taken from mov structures)
coincide. Given that dv_fctx and dv_demux are part of MOVContext, they
would also leak if it would be attempted to 

Re: [FFmpeg-devel] [PATCH] Fix wavpack decoding regression

2022-08-24 Thread Paul B Mahol
will apply soon
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] API documentation

2022-08-24 Thread Michael Riedl

Hi,

I saw on the FFmpeg website that for some stable versions there is no
API documentation. The latest stable documentation (for version 4.1) is
four years old.

We managed to build the API documentation for 5.1
(https://ffmpeg-docs.tools.nativewaves.com/5.1/index.html) and other
stable versions (https://ffmpeg-docs.tools.nativewaves.com/). We happily
offer to host the documentation (updated regularly) free of charge.
Maybe our page can be linked on FFmpeg's documentation page
(https://ffmpeg.org/documentation.html) to complete it with respect to
recent releases.

Please let me know what you think.

Best,
Michael
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 16/18] lavf/dv: set audio bitrate only at stream creation

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> Demuxers are not supposed to update AVCodecParameters after the stream
> was seen by the caller. This value is not important enough to support
> dynamic updates for.
> ---
>  libavformat/dv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index f65c2d596f..9c8b0a262c 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -280,6 +280,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
>  c->ast[i]->codecpar->ch_layout  = 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>  c->ast[i]->start_time   = 0;
> +c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
>  
>  c->audio_pkt[i].size = 0;
>  c->audio_pkt[i].data = c->audio_buf[i];
> @@ -290,7 +291,6 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->audio_pkt[i].pos  = -1;
>  }
>  c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
> -c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
>  }
>  c->ach = ach;
>  

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 15/18] lavf/dv: set non-changing AVStream fields only once

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> ---
>  libavformat/dv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index 24d6897da5..f65c2d596f 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -278,6 +278,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
> c->sys->time_base.den);
>  c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
>  c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
> +c->ast[i]->codecpar->ch_layout  = 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
> +c->ast[i]->start_time   = 0;
>  
>  c->audio_pkt[i].size = 0;
>  c->audio_pkt[i].data = c->audio_buf[i];
> @@ -288,9 +290,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
> uint8_t *frame)
>  c->audio_pkt[i].pos  = -1;
>  }
>  c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
> -c->ast[i]->codecpar->ch_layout  = 
> (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
>  c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
> 16;
> -c->ast[i]->start_time= 0;
>  }
>  c->ach = ach;
>  

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 13/18] lavf/dv: return a meaningful error code from avpriv_dv_produce_packet()

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> ---
>  libavdevice/iec61883.c | 2 +-
>  libavformat/dv.c   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
> index 7223ba2e64..a4b4ce2ef8 100644
> --- a/libavdevice/iec61883.c
> +++ b/libavdevice/iec61883.c
> @@ -209,7 +209,7 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
> *dv, AVPacket *pkt)
>  dv->packets--;
>  
>  if (size < 0)
> -return -1;
> +return size;

Did you test this? iec61883_read_packet() explicitly checks for -1 and
not for < 0 for failure. It should work if you also modify
iec61883_read_packet(), but I never changed this because I don't like to
change code that I can't test.

- Andreas

>  
>  if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
>  av_freep(>data);
> diff --git a/libavformat/dv.c b/libavformat/dv.c
> index f88fe62349..c888111789 100644
> --- a/libavformat/dv.c
> +++ b/libavformat/dv.c
> @@ -404,7 +404,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
> *pkt,
>  if (buf_size < DV_PROFILE_BYTES ||
>  !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
>  buf_size < c->sys->frame_size) {
> -return -1;   /* Broken frame, or not enough data */
> +return AVERROR_INVALIDDATA;
>  }
>  
>  /* Queueing audio packet */

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 07/18] lavc/dv: do not pass DVVideoContext to dv_calculate_mb_xy()

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> Pass the two variables needed from it directly.
> 
> This is done in preparation to splitting DVVideoContext.
> ---
>  libavcodec/dv.h| 5 +++--
>  libavcodec/dvdec.c | 2 +-
>  libavcodec/dvenc.c | 2 +-
>  3 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 286b267de2..6430688795 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -107,7 +107,8 @@ static inline int dv_work_pool_size(const AVDVProfile *d)
>  return size;
>  }
>  
> -static inline void dv_calculate_mb_xy(const DVVideoContext *s,
> +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)
>  {
> @@ -116,7 +117,7 @@ static inline void dv_calculate_mb_xy(const 
> DVVideoContext *s,
>  
>  /* We work with 720p frames split in half.
>   * The odd half-frame (chan == 2,3) is displaced :-( */
> -if (s->sys->height == 720 && !(s->buf[1] & 0x0C))
> +if (sys->height == 720 && !(buf[1] & 0x0C))
>  /* shifting the Y coordinate down by 72/2 macro blocks */
>  *mb_y -= (*mb_y > 17) ? 18 : -72;
>  }
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index 1e2c097ed0..7f9e4eb0c0 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -535,7 +535,7 @@ retry:
>  block = [0][0];
>  mb= mb_data;
>  for (mb_index = 0; mb_index < 5; mb_index++) {
> -dv_calculate_mb_xy(s, work_chunk, mb_index, _x, _y);
> +dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, _x, 
> _y);
>  
>  /* idct_put'ting luminance */
>  if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P)  ||
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index 712ca325de..c12fce9e8b 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -866,7 +866,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, 
> void *arg)
>  p = dif = >buf[work_chunk->buf_offset * 80];
>  enc_blk = _blks[0];
>  for (mb_index = 0; mb_index < 5; mb_index++) {
> -dv_calculate_mb_xy(s, work_chunk, mb_index, _x, _y);
> +dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, _x, 
> _y);
>  
>  qnos[mb_index] = DV_PROFILE_IS_HD(s->sys) ? 1 : 15;
>  

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 10/18] lavc/dv.h: move encoder/decoder-specific code to a new header

2022-08-24 Thread Andreas Rheinhardt
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 
> +
> +#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 00..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 
> +
> +#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 

Re: [FFmpeg-devel] [PATCH 11/18] lavc/dv: rename constants to follow our naming conventions

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> CamelCase for enum tags, ALL_CAPS for enum values.
> ---
>  libavcodec/dv.h | 38 +++---
>  libavcodec/dvdec.c  |  4 ++--
>  libavcodec/dvenc.c  | 32 
>  libavformat/dv.c| 18 +-
>  libavformat/dvenc.c | 34 +-
>  5 files changed, 63 insertions(+), 63 deletions(-)
> 
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 535f01cf0b..29f97b6089 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -27,27 +27,27 @@
>  #ifndef AVCODEC_DV_H
>  #define AVCODEC_DV_H
>  
> -enum dv_section_type {
> -dv_sect_header  = 0x1f,
> -dv_sect_subcode = 0x3f,
> -dv_sect_vaux= 0x56,
> -dv_sect_audio   = 0x76,
> -dv_sect_video   = 0x96,
> +enum DVSectionType {
> +DV_SECT_HEADER  = 0x1f,
> +DV_SECT_SUBCODE = 0x3f,
> +DV_SECT_VAUX= 0x56,
> +DV_SECT_AUDIO   = 0x76,
> +DV_SECT_VIDEO   = 0x96,
>  };
>  
> -enum dv_pack_type {
> -dv_header525 = 0x3f,  /* see dv_write_pack for important details on 
> */
> -dv_header625 = 0xbf,  /* these two packs */
> -dv_timecode  = 0x13,
> -dv_audio_source  = 0x50,
> -dv_audio_control = 0x51,
> -dv_audio_recdate = 0x52,
> -dv_audio_rectime = 0x53,
> -dv_video_source  = 0x60,
> -dv_video_control = 0x61,
> -dv_video_recdate = 0x62,
> -dv_video_rectime = 0x63,
> -dv_unknown_pack  = 0xff,
> +enum DVPackType {
> +DV_HEADER525 = 0x3f,  /* see dv_write_pack for important details on 
> */
> +DV_HEADER625 = 0xbf,  /* these two packs */
> +DV_TIMECODE  = 0x13,
> +DV_AUDIO_SOURCE  = 0x50,
> +DV_AUDIO_CONTROL = 0x51,
> +DV_AUDIO_RECDATE = 0x52,
> +DV_AUDIO_RECTIME = 0x53,
> +DV_VIDEO_SOURCE  = 0x60,
> +DV_VIDEO_CONTROL = 0x61,
> +DV_VIDEO_RECDATE = 0x62,
> +DV_VIDEO_RECTIME = 0x63,
> +DV_UNKNOWN_PACK  = 0xff,
>  };
>  
>  #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index 297bf7f2fb..424aa79f35 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -662,7 +662,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
> AVFrame *frame,
>  
>  /* Determine the codec's sample_aspect ratio from the packet */
>  vsc_pack = buf + 80 * 5 + 48 + 5;
> -if (*vsc_pack == dv_video_control) {
> +if (*vsc_pack == DV_VIDEO_CONTROL) {
>  apt= buf[4] & 0x07;
>  is16_9 = (vsc_pack[2] & 0x07) == 0x02 ||
>   (!apt && (vsc_pack[2] & 0x07) == 0x07);
> @@ -673,7 +673,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
> AVFrame *frame,
>  return ret;
>  
>  /* Determine the codec's field order from the packet */
> -if ( *vsc_pack == dv_video_control ) {
> +if ( *vsc_pack == DV_VIDEO_CONTROL ) {
>  if (avctx->height == 720) {
>  frame->interlaced_frame = 0;
>  frame->top_field_first = 0;
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index 1f0374b865..c0ae4c040a 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -1013,7 +1013,7 @@ static int dv_encode_video_segment(AVCodecContext 
> *avctx, void *arg)
>  return 0;
>  }
>  
> -static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c,
> +static inline int dv_write_pack(enum DVPackType pack_id, DVEncContext *c,
>  uint8_t *buf)
>  {
>  /*
> @@ -1051,8 +1051,8 @@ static inline int dv_write_pack(enum dv_pack_type 
> pack_id, DVEncContext *c,
>  
>  buf[0] = (uint8_t) pack_id;
>  switch (pack_id) {
> -case dv_header525: /* I can't imagine why these two weren't defined as 
> real */
> -case dv_header625: /* packs in SMPTE314M -- they definitely look like 
> ones */
> +case DV_HEADER525: /* I can't imagine why these two weren't defined as 
> real */
> +case DV_HEADER625: /* packs in SMPTE314M -- they definitely look like 
> ones */
>  buf[1] =  0xf8   | /* reserved -- always 1 */
>   (apt & 0x07); /* APT: Track application ID */
>  buf[2] = (0<< 7) | /* TF1: audio data is 0 - valid; 1 - invalid 
> */
> @@ -1065,7 +1065,7 @@ static inline int dv_write_pack(enum dv_pack_type 
> pack_id, DVEncContext *c,
>   (0x0f << 3) | /* reserved -- always 1 */
>   (apt & 0x07); /* AP3: Subcode application ID */
>  break;
> -case dv_video_source:
> +case DV_VIDEO_SOURCE:
>  buf[1] = 0xff; /* reserved -- always 1 */
>  buf[2] = (1 << 7) |/* B/W: 0 - b/w, 1 - color */
>   (1 << 6) |/* following CLF is valid - 0, invalid - 1 */
> @@ -1076,7 +1076,7 @@ static inline int dv_write_pack(enum dv_pack_type 
> pack_id, DVEncContext *c,
>   c->sys->video_stype; /* signal type video compression */
>  buf[4] = 0xff; /* VISC: 0xff -- no information */
>   

Re: [FFmpeg-devel] [PATCH 09/18] lavc/dvenc: stop using DVVideoContext

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> Move the parts of it used by the encoder into a new DVEncContext and
> remove DVVideoContext.
> ---
>  libavcodec/dv.h| 23 ---
>  libavcodec/dvenc.c | 39 ---
>  2 files changed, 28 insertions(+), 34 deletions(-)
> 
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 6430688795..859a4e6545 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -27,36 +27,13 @@
>  #ifndef AVCODEC_DV_H
>  #define AVCODEC_DV_H
>  
> -#include "avcodec.h"
>  #include "dv_profile.h"
> -#include "me_cmp.h"
> -#include "idctdsp.h"
>  
>  typedef struct DVwork_chunk {
>  uint16_t buf_offset;
>  uint16_t mb_coordinates[5];
>  } DVwork_chunk;
>  
> -typedef struct DVVideoContext {
> -AVClass *avclass;
> -const AVDVProfile *sys;
> -const AVFrame   *frame;
> -AVCodecContext  *avctx;
> -uint8_t *buf;
> -
> -uint8_t dv_zigzag[2][64];
> -
> -void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t 
> linesize);
> -void (*fdct[2])(int16_t *block);
> -void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block);
> -me_cmp_func ildct_cmp;
> -DVwork_chunk work_chunks[4 * 12 * 27];
> -uint32_t idct_factor[2 * 4 * 16 * 64];
> -IDCTDSPContext idsp;
> -
> -int quant_deadzone;
> -} DVVideoContext;
> -
>  enum dv_section_type {
>  dv_sect_header  = 0x1f,
>  dv_sect_subcode = 0x3f,
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index c12fce9e8b..19291724e0 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -47,9 +47,26 @@
>  #include "pixblockdsp.h"
>  #include "put_bits.h"
>  
> +typedef struct DVEncContext {
> +AVClass   *class;

Please constify AVClass while at it. LGTM apart from that.

- Andreas

> +const AVDVProfile *sys;
> +const AVFrame *frame;
> +AVCodecContext*avctx;
> +uint8_t   *buf;
> +
> +void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t 
> linesize);
> +void (*fdct[2])(int16_t *block);
> +
> +me_cmp_func  ildct_cmp;
> +DVwork_chunk work_chunks[4 * 12 * 27];
> +
> +int quant_deadzone;
> +} DVEncContext;
> +
> +
>  static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
>  {
> -DVVideoContext *s = avctx->priv_data;
> +DVEncContext *s = avctx->priv_data;
>  FDCTDSPContext fdsp;
>  MECmpContext mecc;
>  PixblockDSPContext pdsp;
> @@ -220,7 +237,7 @@ static av_always_inline PutBitContext 
> *dv_encode_ac(EncBlockInfo *bi,
>  return pb;
>  }
>  
> -static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const 
> uint8_t *data,
> +static av_always_inline int dv_guess_dct_mode(DVEncContext *s, const uint8_t 
> *data,
>ptrdiff_t linesize)
>  {
>  if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
> @@ -368,7 +385,7 @@ static const int dv_weight_720[2][64] = {
>2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
>  };
>  
> -static av_always_inline int dv_set_class_number_sd(DVVideoContext *s,
> +static av_always_inline int dv_set_class_number_sd(DVEncContext *s,
> int16_t *blk, 
> EncBlockInfo *bi,
> const uint8_t 
> *zigzag_scan,
> const int *weight, int 
> bias)
> @@ -452,7 +469,7 @@ static av_always_inline int 
> dv_set_class_number_sd(DVVideoContext *s,
>  
>  /* this function just copies the DCT coefficients and performs
> the initial (non-)quantization. */
> -static inline void dv_set_class_number_hd(DVVideoContext *s,
> +static inline void dv_set_class_number_hd(DVEncContext *s,
>int16_t *blk, EncBlockInfo *bi,
>const uint8_t *zigzag_scan,
>const int *weight, int bias)
> @@ -510,7 +527,7 @@ static inline void dv_set_class_number_hd(DVVideoContext 
> *s,
>  }
>  
>  static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const 
> uint8_t *data, int linesize,
> -  DVVideoContext *s, int chroma)
> +  DVEncContext *s, int chroma)
>  {
>  LOCAL_ALIGNED_16(int16_t, blk, [64]);
>  
> @@ -847,7 +864,7 @@ static inline void dv_revise_cnos(uint8_t *dif, 
> EncBlockInfo *blk, const AVDVPro
>  
>  static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
>  {
> -DVVideoContext *s = avctx->priv_data;
> +DVEncContext *s = avctx->priv_data;
>  DVwork_chunk *work_chunk = arg;
>  int mb_index, i, j;
>  int mb_x, mb_y, c_offset;
> @@ -995,7 +1012,7 @@ static int dv_encode_video_segment(AVCodecContext 
> *avctx, void *arg)
>  return 0;
>  }
>  
> -static inline int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c,
> +static inline int 

Re: [FFmpeg-devel] [PATCH 08/18] lavc/dvdec: stop using DVVideoContext

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> The struct is quite small and the decoder and the encoder use different
> fields from it, so benefits from reusing it are small.
> 
> This allows making the buf field const.
> ---
>  libavcodec/dvdec.c | 28 +---
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index 7f9e4eb0c0..444b137488 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -48,6 +48,7 @@
>  #include "dv_profile_internal.h"
>  #include "dvdata.h"
>  #include "get_bits.h"
> +#include "idctdsp.h"
>  #include "internal.h"
>  #include "put_bits.h"
>  #include "simple_idct.h"
> @@ -63,6 +64,19 @@ typedef struct BlockInfo {
>  int shift_offset;
>  } BlockInfo;
>  
> +typedef struct DVDecContext {
> +const AVDVProfile *sys;
> +const AVFrame *frame;
> +const uint8_t *buf;
> +
> +uint8_t  dv_zigzag[2][64];
> +DVwork_chunk work_chunks[4 * 12 * 27];
> +uint32_t idct_factor[2 * 4 * 16 * 64];
> +void   (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t 
> *block);
> +
> +IDCTDSPContext idsp;
> +} DVDecContext;
> +
>  static const int dv_iweight_bits = 14;
>  
>  static const uint16_t dv_iweight_88[64] = {
> @@ -188,7 +202,7 @@ static void dv_init_static(void)
>  }
>  }
>  
> -static void dv_init_weight_tables(DVVideoContext *ctx, const AVDVProfile *d)
> +static void dv_init_weight_tables(DVDecContext *ctx, const AVDVProfile *d)
>  {
>  int j, i, c, s;
>  uint32_t *factor1 = >idct_factor[0],
> @@ -237,7 +251,7 @@ static void dv_init_weight_tables(DVVideoContext *ctx, 
> const AVDVProfile *d)
>  static av_cold int dvvideo_decode_init(AVCodecContext *avctx)
>  {
>  static AVOnce init_static_once = AV_ONCE_INIT;
> -DVVideoContext *s = avctx->priv_data;
> +DVDecContext *s = avctx->priv_data;
>  int i;
>  
>  avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
> @@ -347,7 +361,7 @@ static av_always_inline void put_block_8x4(int16_t 
> *block, uint8_t *av_restrict
>  }
>  }
>  
> -static void dv100_idct_put_last_row_field_chroma(const DVVideoContext *s, 
> uint8_t *data,
> +static void dv100_idct_put_last_row_field_chroma(const DVDecContext *s, 
> uint8_t *data,
>   int stride, int16_t *blocks)
>  {
>  s->idsp.idct(blocks + 0*64);
> @@ -359,7 +373,7 @@ static void dv100_idct_put_last_row_field_chroma(const 
> DVVideoContext *s, uint8_
>  put_block_8x4(blocks+1*64 + 4*8, data + 8 + stride, stride<<1);
>  }
>  
> -static void dv100_idct_put_last_row_field_luma(const DVVideoContext *s, 
> uint8_t *data,
> +static void dv100_idct_put_last_row_field_luma(const DVDecContext *s, 
> uint8_t *data,
> int stride, int16_t *blocks)
>  {
>  s->idsp.idct(blocks + 0*64);
> @@ -380,7 +394,7 @@ static void dv100_idct_put_last_row_field_luma(const 
> DVVideoContext *s, uint8_t
>  /* mb_x and mb_y are in units of 8 pixels */
>  static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
>  {
> -const DVVideoContext *s = avctx->priv_data;
> +const DVDecContext *s = avctx->priv_data;
>  DVwork_chunk *work_chunk = arg;
>  int quant, dc, dct_mode, class1, j;
>  int mb_index, mb_x, mb_y, last_index;
> @@ -614,7 +628,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
> AVFrame *frame,
>  {
>  uint8_t *buf = avpkt->data;
>  int buf_size = avpkt->size;
> -DVVideoContext *s = avctx->priv_data;
> +DVDecContext *s = avctx->priv_data;
>  const uint8_t *vsc_pack;
>  int apt, is16_9, ret;
>  const AVDVProfile *sys;
> @@ -688,7 +702,7 @@ const FFCodec ff_dvvideo_decoder = {
>  .p.long_name= NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
>  .p.type = AVMEDIA_TYPE_VIDEO,
>  .p.id   = AV_CODEC_ID_DVVIDEO,
> -.priv_data_size = sizeof(DVVideoContext),
> +.priv_data_size = sizeof(DVDecContext),
>  .init   = dvvideo_decode_init,
>  FF_CODEC_DECODE_CB(dvvideo_decode_frame),
>  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | 
> AV_CODEC_CAP_SLICE_THREADS,

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 06/18] lavc/dv: do not pass DVVideoContext to ff_dv_init_dynamic_tables()

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> It only needs work_chunks from it, so pass that directly.
> 
> This is done in preparation to splitting DVVideoContext.
> ---
>  libavcodec/dv.c| 6 +++---
>  libavcodec/dv.h| 2 +-
>  libavcodec/dvdec.c | 2 +-
>  libavcodec/dvenc.c | 2 +-
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/dv.c b/libavcodec/dv.c
> index 9e05aa8927..b5e54de5dd 100644
> --- a/libavcodec/dv.c
> +++ b/libavcodec/dv.c
> @@ -162,7 +162,7 @@ static inline void dv_calc_mb_coordinates(const 
> AVDVProfile *d, int chan,
>  }
>  }
>  
> -int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d)
> +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile 
> *d)
>  {
>  int j, i, c, s, p;
>  
> @@ -174,8 +174,8 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const 
> AVDVProfile *d)
>  p += !(j % 3);
>  if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
>  !(DV_PROFILE_IS_720p50(d) && s > 9)) {
> -dv_calc_mb_coordinates(d, c, s, j, 
> >work_chunks[i].mb_coordinates[0]);
> -ctx->work_chunks[i++].buf_offset = p;
> +dv_calc_mb_coordinates(d, c, s, j, 
> _chunks[i].mb_coordinates[0]);
> +work_chunks[i++].buf_offset = p;
>  }
>  p += 5;
>  }
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 2b082d0140..286b267de2 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -95,7 +95,7 @@ enum dv_pack_type {
>   */
>  #define DV_MAX_BPM 8
>  
> -int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d);
> +int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile 
> *d);
>  
>  static inline int dv_work_pool_size(const AVDVProfile *d)
>  {
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index daee2347e6..1e2c097ed0 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -626,7 +626,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
> AVFrame *frame,
>  }
>  
>  if (sys != s->sys) {
> -ret = ff_dv_init_dynamic_tables(s, sys);
> +ret = ff_dv_init_dynamic_tables(s->work_chunks, sys);
>  if (ret < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Error initializing the work 
> tables.\n");
>  return ret;
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index 8027feb9b3..712ca325de 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -67,7 +67,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
> *avctx)
>  return AVERROR(EINVAL);
>  }
>  
> -ret = ff_dv_init_dynamic_tables(s, s->sys);
> +ret = ff_dv_init_dynamic_tables(s->work_chunks, s->sys);
>  if (ret < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n");
>  return ret;

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 05/18] lavc/dv: remove ff_dvvideo_init()

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> The function contains only two assignments, which are simpler to
> duplicate into decoder and encoder. Additionally, dvdec does not use
> DVVideoContext.avctx at all.
> ---
>  libavcodec/dv.c| 10 --
>  libavcodec/dv.h|  2 --
>  libavcodec/dvdec.c |  4 +++-
>  libavcodec/dvenc.c |  5 -
>  4 files changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/dv.c b/libavcodec/dv.c
> index e2550c4cc1..9e05aa8927 100644
> --- a/libavcodec/dv.c
> +++ b/libavcodec/dv.c
> @@ -184,13 +184,3 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const 
> AVDVProfile *d)
>  
>  return 0;
>  }
> -
> -av_cold int ff_dvvideo_init(AVCodecContext *avctx)
> -{
> -DVVideoContext *s = avctx->priv_data;
> -
> -s->avctx = avctx;
> -avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
> -
> -return 0;
> -}
> diff --git a/libavcodec/dv.h b/libavcodec/dv.h
> index 331b8e846a..2b082d0140 100644
> --- a/libavcodec/dv.h
> +++ b/libavcodec/dv.h
> @@ -97,8 +97,6 @@ enum dv_pack_type {
>  
>  int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d);
>  
> -int ff_dvvideo_init(AVCodecContext *avctx);
> -
>  static inline int dv_work_pool_size(const AVDVProfile *d)
>  {
>  int size = d->n_difchan * d->difseg_size * 27;
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index bad8419925..daee2347e6 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -240,6 +240,8 @@ static av_cold int dvvideo_decode_init(AVCodecContext 
> *avctx)
>  DVVideoContext *s = avctx->priv_data;
>  int i;
>  
> +avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
> +
>  ff_idctdsp_init(>idsp, avctx);
>  
>  for (i = 0; i < 64; i++)
> @@ -258,7 +260,7 @@ static av_cold int dvvideo_decode_init(AVCodecContext 
> *avctx)
>  
>  ff_thread_once(_static_once, dv_init_static);
>  
> -return ff_dvvideo_init(avctx);
> +return 0;
>  }
>  
>  /* decode AC coefficients */
> diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
> index 5ba4de3213..8027feb9b3 100644
> --- a/libavcodec/dvenc.c
> +++ b/libavcodec/dvenc.c
> @@ -55,6 +55,9 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
> *avctx)
>  PixblockDSPContext pdsp;
>  int ret;
>  
> +s->avctx = avctx;
> +avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
> +
>  s->sys = av_dv_codec_profile2(avctx->width, avctx->height, 
> avctx->pix_fmt, avctx->time_base);
>  if (!s->sys) {
>  av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. 
> "
> @@ -91,7 +94,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext 
> *avctx)
>  }
>  #endif
>  
> -return ff_dvvideo_init(avctx);
> +return 0;
>  }
>  
>  /* bit budget for AC only in 5 MBs */

There is actually another issue here: Encoders are not supposed to set
chroma_sample_location at all according to the documentation. I sent a
patch to implement this
(https://ffmpeg.org/pipermail/ffmpeg-devel/2022-July/298518.html -- it
also inlines and removes ff_dvvideo_init()), but I am unsure whether it
is not the documentation that needs to be updated.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 04/18] lavc/dvdec: drop the only use of DVVideoContext.avctx

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> The function gets the codec context parameter directly.
> ---
>  libavcodec/dvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
> index f7423580aa..bad8419925 100644
> --- a/libavcodec/dvdec.c
> +++ b/libavcodec/dvdec.c
> @@ -393,7 +393,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, 
> void *arg)
>  LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]);
>  LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 
> AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
>  LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + 
> AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
> -const int log2_blocksize = 3-s->avctx->lowres;
> +const int log2_blocksize = 3 - avctx->lowres;
>  int is_field_mode[5];
>  int vs_bit_buffer_damaged = 0;
>  int mb_bit_buffer_damaged[5] = {0};

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 02/18] lavf/dv: remove DVMuxContext declaration from dv.h

2022-08-24 Thread Andreas Rheinhardt
Anton Khirnov:
> DVMuxContext is only used inside dvenc.c, there is no reason for it to
> be visible outside of that file.
> ---
>  libavformat/dv.h| 4 +---
>  libavformat/dvenc.c | 4 ++--
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/dv.h b/libavformat/dv.h
> index 160c6ab873..efced6ccf0 100644
> --- a/libavformat/dv.h
> +++ b/libavformat/dv.h
> @@ -1,5 +1,5 @@
>  /*
> - * General DV muxer/demuxer
> + * General DV demuxer
>   * Copyright (c) 2003 Roman Shaposhnik
>   *
>   * Many thanks to Dan Dennedy  for providing wealth
> @@ -36,6 +36,4 @@ int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *);
>  int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, 
> int64_t);
>  void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
>  
> -typedef struct DVMuxContext DVMuxContext;
> -
>  #endif /* AVFORMAT_DV_H */
> diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
> index 7ef9692302..429ddcb96c 100644
> --- a/libavformat/dvenc.c
> +++ b/libavformat/dvenc.c
> @@ -43,7 +43,7 @@
>  
>  #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32-bit audio
>  
> -struct DVMuxContext {
> +typedef struct DVMuxContext {
>  AVClass  *av_class;
>  const AVDVProfile*  sys;   /* current DV profile, e.g.: 525/60, 
> 625/50 */
>  int   n_ast; /* number of stereo audio streams (up 
> to 2) */
> @@ -55,7 +55,7 @@ struct DVMuxContext {
>  int   has_video; /* frame under construction has video */
>  uint8_t   frame_buf[DV_MAX_FRAME_SIZE]; /* frame under 
> construction */
>  AVTimecodetc;/* timecode context */
> -};
> +} DVMuxContext;
>  
>  static const int dv_aaux_packs_dist[12][9] = {
>  { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },

LGTM.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 01/18] tests/fate/mov: add a test for dv audio demuxed through dv demuxer

2022-08-24 Thread Anton Khirnov
Unfortunately the smallest sample I could come up with for this is 4MB,
it can be downloaded from [1] and is a cut version of [2]. Smaller
samples for this feature are very much welcome.

[1] 
https://ups.khirnov.net/9c5dbaa0847185b81c62d48608eec60440b2cb016899a7d6214f5c30efc81934/qt_dv_pal_test_cut.mov
[2] https://samples.ffmpeg.org/V-codecs/DVSD/qt_dv_pal_test.mov

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH] avfilter/vf_frei0r: set align to 1 for frei0r frames

2022-08-24 Thread Brendan Hack
The frei0r API requires linesize to be width * 4.
Since the align property of ff_default_get_video_buffer2
specifies line alignment, not buffer alignment, the
previous value of 16 breaks this requirement for frames
whose width is a multiple of 8, but not a multiple of 16
as it adds extra padding to ensure line aligment.

Fix Trac ticket #9873
---
 libavfilter/vf_frei0r.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 1e01114b76..58fa2245bf 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -359,14 +359,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 Frei0rContext *s = inlink->dst->priv;
 AVFilterLink *outlink = inlink->dst->outputs[0];
-AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
+/* align parameter is the line alignment, not the buffer alignment.
+ * frei0r expects line size to be width*4 so we want an align of 1
+ * to ensure lines aren't padded out. */
+AVFrame *out = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 1);
 if (!out)
 goto fail;
 
 av_frame_copy_props(out, in);
 
 if (in->linesize[0] != out->linesize[0]) {
-AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
+AVFrame *in2 = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 1);
 if (!in2)
 goto fail;
 av_frame_copy(in2, in);
@@ -481,7 +484,7 @@ static int source_config_props(AVFilterLink *outlink)
 static int source_request_frame(AVFilterLink *outlink)
 {
 Frei0rContext *s = outlink->src->priv;
-AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 16);
+AVFrame *frame = ff_default_get_video_buffer2(outlink, outlink->w, 
outlink->h, 1);
 
 if (!frame)
 return AVERROR(ENOMEM);
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 10/18] lavc/dv.h: move encoder/decoder-specific code to a new header

2022-08-24 Thread 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 
+
+#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 00..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 
+
+#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 

[FFmpeg-devel] [PATCH 17/18] lavf/dv: do not update AVCodecParameters.sample_rate while demuxing

2022-08-24 Thread Anton Khirnov
Demuxers are not allowed to do this and few callers, if any, will handle
this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data
instead.
---
 libavformat/dv.c | 49 +---
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 9c8b0a262c..ffed1a7a90 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -33,6 +33,7 @@
 
 #include 
 #include "avformat.h"
+#include "demux.h"
 #include "internal.h"
 #include "libavcodec/dv_profile.h"
 #include "libavcodec/dv.h"
@@ -46,7 +47,7 @@
 #if CONFIG_DV_DEMUXER
 
 // Must be kept in sync with AVPacket
-struct DVPacket {
+typedef struct DVPacket {
 int64_t  pts;
 uint8_t *data;
 int  size;
@@ -54,7 +55,10 @@ struct DVPacket {
 int  flags;
 int64_t  pos;
 int64_t  duration;
-};
+
+int sample_rate;
+int last_sample_rate;
+} DVPacket;
 
 struct DVDemuxContext {
 const AVDVProfile*  sys;/* Current DV profile. E.g.: 525/60, 625/50 */
@@ -237,7 +241,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t 
**ppcm,
 static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
 {
 const uint8_t *as_pack;
-int freq, stype, smpls, quant, i, ach;
+int freq, stype, smpls, quant, i, ach, sr;
 
 as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE);
 if (!as_pack || !c->sys) {/* No audio ? */
@@ -255,6 +259,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
"Unrecognized audio sample rate index (%d)\n", freq);
 return 0;
 }
+sr = dv_audio_frequency[freq];
 
 if (stype > 3) {
 av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype);
@@ -280,7 +285,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
 c->ast[i]->codecpar->ch_layout  = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 c->ast[i]->start_time   = 0;
-c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
16;
+c->ast[i]->codecpar->bit_rate   = 2 * sr * 16;
+
+c->ast[i]->codecpar->sample_rate = sr;
+c->audio_pkt[i].last_sample_rate = sr;
 
 c->audio_pkt[i].size = 0;
 c->audio_pkt[i].data = c->audio_buf[i];
@@ -290,7 +298,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->audio_pkt[i].duration = 0;
 c->audio_pkt[i].pos  = -1;
 }
-c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
+
+c->audio_pkt[i].sample_rate = sr;
 }
 c->ach = ach;
 
@@ -380,16 +389,26 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt)
 
 for (i = 0; i < c->ach; i++) {
 if (c->ast[i] && c->audio_pkt[i].size) {
-pkt->size = c->audio_pkt[i].size;
-pkt->data = c->audio_pkt[i].data;
-pkt->stream_index = c->audio_pkt[i].stream_index;
-pkt->flags= c->audio_pkt[i].flags;
-pkt->pts  = c->audio_pkt[i].pts;
-pkt->duration = c->audio_pkt[i].duration;
-pkt->pos  = c->audio_pkt[i].pos;
-
-c->audio_pkt[i].size = 0;
-size = pkt->size;
+DVPacket *dpkt = >audio_pkt[i];
+
+pkt->size = dpkt->size;
+pkt->data = dpkt->data;
+pkt->stream_index = dpkt->stream_index;
+pkt->flags= dpkt->flags;
+pkt->pts  = dpkt->pts;
+pkt->duration = dpkt->duration;
+pkt->pos  = dpkt->pos;
+
+dpkt->size = 0;
+size   = pkt->size;
+
+if (dpkt->last_sample_rate != dpkt->sample_rate) {
+int ret = ff_add_param_change(pkt, 0, 0, dpkt->sample_rate, 0, 
0);
+if (ret < 0)
+return ret;
+dpkt->last_sample_rate = dpkt->sample_rate;
+}
+
 break;
 }
 }
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 16/18] lavf/dv: set audio bitrate only at stream creation

2022-08-24 Thread Anton Khirnov
Demuxers are not supposed to update AVCodecParameters after the stream
was seen by the caller. This value is not important enough to support
dynamic updates for.
---
 libavformat/dv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index f65c2d596f..9c8b0a262c 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -280,6 +280,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
 c->ast[i]->codecpar->ch_layout  = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 c->ast[i]->start_time   = 0;
+c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
16;
 
 c->audio_pkt[i].size = 0;
 c->audio_pkt[i].data = c->audio_buf[i];
@@ -290,7 +291,6 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->audio_pkt[i].pos  = -1;
 }
 c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
-c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
16;
 }
 c->ach = ach;
 
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 13/18] lavf/dv: return a meaningful error code from avpriv_dv_produce_packet()

2022-08-24 Thread Anton Khirnov
---
 libavdevice/iec61883.c | 2 +-
 libavformat/dv.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 7223ba2e64..a4b4ce2ef8 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -209,7 +209,7 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 dv->packets--;
 
 if (size < 0)
-return -1;
+return size;
 
 if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
 av_freep(>data);
diff --git a/libavformat/dv.c b/libavformat/dv.c
index f88fe62349..c888111789 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -404,7 +404,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 if (buf_size < DV_PROFILE_BYTES ||
 !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
 buf_size < c->sys->frame_size) {
-return -1;   /* Broken frame, or not enough data */
+return AVERROR_INVALIDDATA;
 }
 
 /* Queueing audio packet */
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 08/18] lavc/dvdec: stop using DVVideoContext

2022-08-24 Thread Anton Khirnov
The struct is quite small and the decoder and the encoder use different
fields from it, so benefits from reusing it are small.

This allows making the buf field const.
---
 libavcodec/dvdec.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 7f9e4eb0c0..444b137488 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -48,6 +48,7 @@
 #include "dv_profile_internal.h"
 #include "dvdata.h"
 #include "get_bits.h"
+#include "idctdsp.h"
 #include "internal.h"
 #include "put_bits.h"
 #include "simple_idct.h"
@@ -63,6 +64,19 @@ typedef struct BlockInfo {
 int shift_offset;
 } BlockInfo;
 
+typedef struct DVDecContext {
+const AVDVProfile *sys;
+const AVFrame *frame;
+const uint8_t *buf;
+
+uint8_t  dv_zigzag[2][64];
+DVwork_chunk work_chunks[4 * 12 * 27];
+uint32_t idct_factor[2 * 4 * 16 * 64];
+void   (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block);
+
+IDCTDSPContext idsp;
+} DVDecContext;
+
 static const int dv_iweight_bits = 14;
 
 static const uint16_t dv_iweight_88[64] = {
@@ -188,7 +202,7 @@ static void dv_init_static(void)
 }
 }
 
-static void dv_init_weight_tables(DVVideoContext *ctx, const AVDVProfile *d)
+static void dv_init_weight_tables(DVDecContext *ctx, const AVDVProfile *d)
 {
 int j, i, c, s;
 uint32_t *factor1 = >idct_factor[0],
@@ -237,7 +251,7 @@ static void dv_init_weight_tables(DVVideoContext *ctx, 
const AVDVProfile *d)
 static av_cold int dvvideo_decode_init(AVCodecContext *avctx)
 {
 static AVOnce init_static_once = AV_ONCE_INIT;
-DVVideoContext *s = avctx->priv_data;
+DVDecContext *s = avctx->priv_data;
 int i;
 
 avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
@@ -347,7 +361,7 @@ static av_always_inline void put_block_8x4(int16_t *block, 
uint8_t *av_restrict
 }
 }
 
-static void dv100_idct_put_last_row_field_chroma(const DVVideoContext *s, 
uint8_t *data,
+static void dv100_idct_put_last_row_field_chroma(const DVDecContext *s, 
uint8_t *data,
  int stride, int16_t *blocks)
 {
 s->idsp.idct(blocks + 0*64);
@@ -359,7 +373,7 @@ static void dv100_idct_put_last_row_field_chroma(const 
DVVideoContext *s, uint8_
 put_block_8x4(blocks+1*64 + 4*8, data + 8 + stride, stride<<1);
 }
 
-static void dv100_idct_put_last_row_field_luma(const DVVideoContext *s, 
uint8_t *data,
+static void dv100_idct_put_last_row_field_luma(const DVDecContext *s, uint8_t 
*data,
int stride, int16_t *blocks)
 {
 s->idsp.idct(blocks + 0*64);
@@ -380,7 +394,7 @@ static void dv100_idct_put_last_row_field_luma(const 
DVVideoContext *s, uint8_t
 /* mb_x and mb_y are in units of 8 pixels */
 static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
 {
-const DVVideoContext *s = avctx->priv_data;
+const DVDecContext *s = avctx->priv_data;
 DVwork_chunk *work_chunk = arg;
 int quant, dc, dct_mode, class1, j;
 int mb_index, mb_x, mb_y, last_index;
@@ -614,7 +628,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 {
 uint8_t *buf = avpkt->data;
 int buf_size = avpkt->size;
-DVVideoContext *s = avctx->priv_data;
+DVDecContext *s = avctx->priv_data;
 const uint8_t *vsc_pack;
 int apt, is16_9, ret;
 const AVDVProfile *sys;
@@ -688,7 +702,7 @@ const FFCodec ff_dvvideo_decoder = {
 .p.long_name= NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
 .p.type = AVMEDIA_TYPE_VIDEO,
 .p.id   = AV_CODEC_ID_DVVIDEO,
-.priv_data_size = sizeof(DVVideoContext),
+.priv_data_size = sizeof(DVDecContext),
 .init   = dvvideo_decode_init,
 FF_CODEC_DECODE_CB(dvvideo_decode_frame),
 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | 
AV_CODEC_CAP_SLICE_THREADS,
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 05/18] lavc/dv: remove ff_dvvideo_init()

2022-08-24 Thread Anton Khirnov
The function contains only two assignments, which are simpler to
duplicate into decoder and encoder. Additionally, dvdec does not use
DVVideoContext.avctx at all.
---
 libavcodec/dv.c| 10 --
 libavcodec/dv.h|  2 --
 libavcodec/dvdec.c |  4 +++-
 libavcodec/dvenc.c |  5 -
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index e2550c4cc1..9e05aa8927 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -184,13 +184,3 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const 
AVDVProfile *d)
 
 return 0;
 }
-
-av_cold int ff_dvvideo_init(AVCodecContext *avctx)
-{
-DVVideoContext *s = avctx->priv_data;
-
-s->avctx = avctx;
-avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
-
-return 0;
-}
diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 331b8e846a..2b082d0140 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -97,8 +97,6 @@ enum dv_pack_type {
 
 int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d);
 
-int ff_dvvideo_init(AVCodecContext *avctx);
-
 static inline int dv_work_pool_size(const AVDVProfile *d)
 {
 int size = d->n_difchan * d->difseg_size * 27;
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index bad8419925..daee2347e6 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -240,6 +240,8 @@ static av_cold int dvvideo_decode_init(AVCodecContext 
*avctx)
 DVVideoContext *s = avctx->priv_data;
 int i;
 
+avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
+
 ff_idctdsp_init(>idsp, avctx);
 
 for (i = 0; i < 64; i++)
@@ -258,7 +260,7 @@ static av_cold int dvvideo_decode_init(AVCodecContext 
*avctx)
 
 ff_thread_once(_static_once, dv_init_static);
 
-return ff_dvvideo_init(avctx);
+return 0;
 }
 
 /* decode AC coefficients */
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5ba4de3213..8027feb9b3 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -55,6 +55,9 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 PixblockDSPContext pdsp;
 int ret;
 
+s->avctx = avctx;
+avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT;
+
 s->sys = av_dv_codec_profile2(avctx->width, avctx->height, avctx->pix_fmt, 
avctx->time_base);
 if (!s->sys) {
 av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
@@ -91,7 +94,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 }
 #endif
 
-return ff_dvvideo_init(avctx);
+return 0;
 }
 
 /* bit budget for AC only in 5 MBs */
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 15/18] lavf/dv: set non-changing AVStream fields only once

2022-08-24 Thread Anton Khirnov
---
 libavformat/dv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 24d6897da5..f65c2d596f 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -278,6 +278,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
c->sys->time_base.den);
 c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
+c->ast[i]->codecpar->ch_layout  = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
+c->ast[i]->start_time   = 0;
 
 c->audio_pkt[i].size = 0;
 c->audio_pkt[i].data = c->audio_buf[i];
@@ -288,9 +290,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->audio_pkt[i].pos  = -1;
 }
 c->ast[i]->codecpar->sample_rate= dv_audio_frequency[freq];
-c->ast[i]->codecpar->ch_layout  = 
(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
 c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
16;
-c->ast[i]->start_time= 0;
 }
 c->ach = ach;
 
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 14/18] lavf/dv: forward errors from avformat_new_stream()

2022-08-24 Thread Anton Khirnov
---
 libavformat/dv.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index c888111789..24d6897da5 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -268,11 +268,13 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 ach = 2;
 
 /* Dynamic handling of the audio streams in DV */
+c->ach = 0;
 for (i = 0; i < ach; i++) {
 if (!c->ast[i]) {
 c->ast[i] = avformat_new_stream(c->fctx, NULL);
 if (!c->ast[i])
-break;
+return AVERROR(ENOMEM);
+
 avpriv_set_pts_info(c->ast[i], 64, c->sys->time_base.num, 
c->sys->time_base.den);
 c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 c->ast[i]->codecpar->codec_id   = AV_CODEC_ID_PCM_S16LE;
@@ -290,7 +292,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const 
uint8_t *frame)
 c->ast[i]->codecpar->bit_rate   = 2 * dv_audio_frequency[freq] * 
16;
 c->ast[i]->start_time= 0;
 }
-c->ach = i;
+c->ach = ach;
 
 return (c->sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */
 }
@@ -410,6 +412,9 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 /* Queueing audio packet */
 /* FIXME: in case of no audio/bad audio we have to do something */
 size = dv_extract_audio_info(c, buf);
+if (size < 0)
+return size;
+
 for (i = 0; i < c->ach; i++) {
 c->audio_pkt[i].pos  = pos;
 c->audio_pkt[i].size = size;
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 11/18] lavc/dv: rename constants to follow our naming conventions

2022-08-24 Thread Anton Khirnov
CamelCase for enum tags, ALL_CAPS for enum values.
---
 libavcodec/dv.h | 38 +++---
 libavcodec/dvdec.c  |  4 ++--
 libavcodec/dvenc.c  | 32 
 libavformat/dv.c| 18 +-
 libavformat/dvenc.c | 34 +-
 5 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 535f01cf0b..29f97b6089 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -27,27 +27,27 @@
 #ifndef AVCODEC_DV_H
 #define AVCODEC_DV_H
 
-enum dv_section_type {
-dv_sect_header  = 0x1f,
-dv_sect_subcode = 0x3f,
-dv_sect_vaux= 0x56,
-dv_sect_audio   = 0x76,
-dv_sect_video   = 0x96,
+enum DVSectionType {
+DV_SECT_HEADER  = 0x1f,
+DV_SECT_SUBCODE = 0x3f,
+DV_SECT_VAUX= 0x56,
+DV_SECT_AUDIO   = 0x76,
+DV_SECT_VIDEO   = 0x96,
 };
 
-enum dv_pack_type {
-dv_header525 = 0x3f,  /* see dv_write_pack for important details on */
-dv_header625 = 0xbf,  /* these two packs */
-dv_timecode  = 0x13,
-dv_audio_source  = 0x50,
-dv_audio_control = 0x51,
-dv_audio_recdate = 0x52,
-dv_audio_rectime = 0x53,
-dv_video_source  = 0x60,
-dv_video_control = 0x61,
-dv_video_recdate = 0x62,
-dv_video_rectime = 0x63,
-dv_unknown_pack  = 0xff,
+enum DVPackType {
+DV_HEADER525 = 0x3f,  /* see dv_write_pack for important details on */
+DV_HEADER625 = 0xbf,  /* these two packs */
+DV_TIMECODE  = 0x13,
+DV_AUDIO_SOURCE  = 0x50,
+DV_AUDIO_CONTROL = 0x51,
+DV_AUDIO_RECDATE = 0x52,
+DV_AUDIO_RECTIME = 0x53,
+DV_VIDEO_SOURCE  = 0x60,
+DV_VIDEO_CONTROL = 0x61,
+DV_VIDEO_RECDATE = 0x62,
+DV_VIDEO_RECTIME = 0x63,
+DV_UNKNOWN_PACK  = 0xff,
 };
 
 #define DV_PROFILE_IS_HD(p) ((p)->video_stype & 0x10)
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 297bf7f2fb..424aa79f35 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -662,7 +662,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 
 /* Determine the codec's sample_aspect ratio from the packet */
 vsc_pack = buf + 80 * 5 + 48 + 5;
-if (*vsc_pack == dv_video_control) {
+if (*vsc_pack == DV_VIDEO_CONTROL) {
 apt= buf[4] & 0x07;
 is16_9 = (vsc_pack[2] & 0x07) == 0x02 ||
  (!apt && (vsc_pack[2] & 0x07) == 0x07);
@@ -673,7 +673,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 return ret;
 
 /* Determine the codec's field order from the packet */
-if ( *vsc_pack == dv_video_control ) {
+if ( *vsc_pack == DV_VIDEO_CONTROL ) {
 if (avctx->height == 720) {
 frame->interlaced_frame = 0;
 frame->top_field_first = 0;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 1f0374b865..c0ae4c040a 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -1013,7 +1013,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, 
void *arg)
 return 0;
 }
 
-static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c,
+static inline int dv_write_pack(enum DVPackType pack_id, DVEncContext *c,
 uint8_t *buf)
 {
 /*
@@ -1051,8 +1051,8 @@ static inline int dv_write_pack(enum dv_pack_type 
pack_id, DVEncContext *c,
 
 buf[0] = (uint8_t) pack_id;
 switch (pack_id) {
-case dv_header525: /* I can't imagine why these two weren't defined as 
real */
-case dv_header625: /* packs in SMPTE314M -- they definitely look like ones 
*/
+case DV_HEADER525: /* I can't imagine why these two weren't defined as 
real */
+case DV_HEADER625: /* packs in SMPTE314M -- they definitely look like ones 
*/
 buf[1] =  0xf8   | /* reserved -- always 1 */
  (apt & 0x07); /* APT: Track application ID */
 buf[2] = (0<< 7) | /* TF1: audio data is 0 - valid; 1 - invalid */
@@ -1065,7 +1065,7 @@ static inline int dv_write_pack(enum dv_pack_type 
pack_id, DVEncContext *c,
  (0x0f << 3) | /* reserved -- always 1 */
  (apt & 0x07); /* AP3: Subcode application ID */
 break;
-case dv_video_source:
+case DV_VIDEO_SOURCE:
 buf[1] = 0xff; /* reserved -- always 1 */
 buf[2] = (1 << 7) |/* B/W: 0 - b/w, 1 - color */
  (1 << 6) |/* following CLF is valid - 0, invalid - 1 */
@@ -1076,7 +1076,7 @@ static inline int dv_write_pack(enum dv_pack_type 
pack_id, DVEncContext *c,
  c->sys->video_stype; /* signal type video compression */
 buf[4] = 0xff; /* VISC: 0xff -- no information */
 break;
-case dv_video_control:
+case DV_VIDEO_CONTROL:
 buf[1] = (0 << 6) |/* Copy generation management (CGMS) 0 -- free 
*/
  0x3f; /* reserved -- always 1 */
 buf[2] = 0xc8 |/* reserved -- always b11001xxx */
@@ 

[FFmpeg-devel] [PATCH 07/18] lavc/dv: do not pass DVVideoContext to dv_calculate_mb_xy()

2022-08-24 Thread Anton Khirnov
Pass the two variables needed from it directly.

This is done in preparation to splitting DVVideoContext.
---
 libavcodec/dv.h| 5 +++--
 libavcodec/dvdec.c | 2 +-
 libavcodec/dvenc.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 286b267de2..6430688795 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -107,7 +107,8 @@ static inline int dv_work_pool_size(const AVDVProfile *d)
 return size;
 }
 
-static inline void dv_calculate_mb_xy(const DVVideoContext *s,
+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)
 {
@@ -116,7 +117,7 @@ static inline void dv_calculate_mb_xy(const DVVideoContext 
*s,
 
 /* We work with 720p frames split in half.
  * The odd half-frame (chan == 2,3) is displaced :-( */
-if (s->sys->height == 720 && !(s->buf[1] & 0x0C))
+if (sys->height == 720 && !(buf[1] & 0x0C))
 /* shifting the Y coordinate down by 72/2 macro blocks */
 *mb_y -= (*mb_y > 17) ? 18 : -72;
 }
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 1e2c097ed0..7f9e4eb0c0 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -535,7 +535,7 @@ retry:
 block = [0][0];
 mb= mb_data;
 for (mb_index = 0; mb_index < 5; mb_index++) {
-dv_calculate_mb_xy(s, work_chunk, mb_index, _x, _y);
+dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, _x, _y);
 
 /* idct_put'ting luminance */
 if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P)  ||
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 712ca325de..c12fce9e8b 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -866,7 +866,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, 
void *arg)
 p = dif = >buf[work_chunk->buf_offset * 80];
 enc_blk = _blks[0];
 for (mb_index = 0; mb_index < 5; mb_index++) {
-dv_calculate_mb_xy(s, work_chunk, mb_index, _x, _y);
+dv_calculate_mb_xy(s->sys, s->buf, work_chunk, mb_index, _x, _y);
 
 qnos[mb_index] = DV_PROFILE_IS_HD(s->sys) ? 1 : 15;
 
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 12/18] lavf/dv: make returning the video packet optional

2022-08-24 Thread Anton Khirnov
The mov demuxer only returns DV audio, video packets are discarded.

It first reads the data to be parsed into a packet. Then both this
packet and the pointer to its data are passed together to
avpriv_dv_produce_packet(), which parses the data and partially
overwrites the packet. This is confusing and potentially dangerous, so
just pass NULL and avoid pointless packet modification.
---
 libavformat/dv.c  | 19 +++
 libavformat/mov.c |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index 303cecf9bb..f88fe62349 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -430,14 +430,17 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 }
 }
 
-/* Now it's time to return video packet */
-size = dv_extract_video_info(c, buf);
-pkt->data = buf;
-pkt->pos  = pos;
-pkt->size = size;
-pkt->flags   |= AV_PKT_FLAG_KEY;
-pkt->stream_index = c->vst->index;
-pkt->pts  = c->frames;
+/* return the video packet, if the caller wants it */
+if (pkt) {
+size = dv_extract_video_info(c, buf);
+
+pkt->data = buf;
+pkt->pos  = pos;
+pkt->size = size;
+pkt->flags   |= AV_PKT_FLAG_KEY;
+pkt->stream_index = c->vst->index;
+pkt->pts  = c->frames;
+}
 
 c->frames++;
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1d8c5b2904..a2b429e52f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8768,7 +8768,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 #if CONFIG_DV_DEMUXER
 if (mov->dv_demux && sc->dv_audio_container) {
-ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, 
pkt->size, pkt->pos);
+ret = avpriv_dv_produce_packet(mov->dv_demux, NULL, pkt->data, 
pkt->size, pkt->pos);
 av_packet_unref(pkt);
 if (ret < 0)
 return ret;
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 18/18] lavf/dv: do not continuously set stream timebase

2022-08-24 Thread Anton Khirnov
The code will call avpriv_set_pts_info() for each video frame, possibly
setting a different timebase if the stream framerate changes. This
violates API conventions, as the timebase is supposed to stay constant
after stream creation.

Change the demuxer to set a single timebase that is granular enough to
handle all supported DV framerates.

The seek tests change slightly because the new timebase is more
granular.
---
 libavformat/dv.c  | 16 
 tests/ref/seek/lavf-dv| 30 +++---
 tests/ref/seek/vsynth_lena-dv | 24 
 tests/ref/seek/vsynth_lena-dv-411 | 24 
 tests/ref/seek/vsynth_lena-dv-50  | 24 
 5 files changed, 63 insertions(+), 55 deletions(-)

diff --git a/libavformat/dv.c b/libavformat/dv.c
index ffed1a7a90..e2f7a6d313 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -69,6 +69,8 @@ struct DVDemuxContext {
 uint8_t   audio_buf[4][8192];
 int   ach;
 int   frames;
+
+int64_t   next_pts;
 };
 
 static inline uint16_t dv_audio_12to16(uint16_t sample)
@@ -314,8 +316,6 @@ static int dv_extract_video_info(DVDemuxContext *c, const 
uint8_t *frame)
 
 par = c->vst->codecpar;
 
-avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
-c->sys->time_base.den);
 c->vst->avg_frame_rate = av_inv_q(c->vst->time_base);
 
 /* finding out SAR is a little bit messy */
@@ -360,6 +360,8 @@ static int dv_init_demux(AVFormatContext *s, DVDemuxContext 
*c)
 c->vst->codecpar->bit_rate   = 2500;
 c->vst->start_time= 0;
 
+avpriv_set_pts_info(c->vst, 64, 1, 6);
+
 /* Audio streams are added later as they are encountered. */
 s->ctx_flags |= AVFMTCTX_NOHEADER;
 
@@ -463,7 +465,10 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket 
*pkt,
 pkt->size = size;
 pkt->flags   |= AV_PKT_FLAG_KEY;
 pkt->stream_index = c->vst->index;
-pkt->pts  = c->frames;
+pkt->pts  = c->next_pts;
+pkt->duration = av_rescale_q(1, c->sys->time_base, 
c->vst->time_base);
+
+c->next_pts += pkt->duration;
 }
 
 c->frames++;
@@ -477,11 +482,12 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
 // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
 FFFormatContext *const si = ffformatcontext(s);
 const int frame_size = c->sys->frame_size;
+int64_t  frame_count = av_rescale_q(timestamp, c->vst->time_base, 
c->sys->time_base);
 int64_t offset;
 int64_t size   = avio_size(s->pb) - si->data_offset;
 int64_t max_offset = ((size - 1) / frame_size) * frame_size;
 
-offset = frame_size * timestamp;
+offset = frame_size * frame_count;
 
 if (size >= 0 && offset > max_offset)
 offset = max_offset;
@@ -494,6 +500,8 @@ static int64_t dv_frame_offset(AVFormatContext *s, 
DVDemuxContext *c,
 void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
 {
 c->frames = frame_offset;
+if (c->sys)
+c->next_pts = av_rescale_q(frame_offset, c->sys->time_base, 
c->vst->time_base);
 c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
 c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
 }
diff --git a/tests/ref/seek/lavf-dv b/tests/ref/seek/lavf-dv
index f63e4460be..356f05546b 100644
--- a/tests/ref/seek/lavf-dv
+++ b/tests/ref/seek/lavf-dv
@@ -3,50 +3,50 @@ ret: 0 st:-1 flags:0  ts:-1.00
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 ret: 0 st:-1 flags:1  ts: 1.894167
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 st: 0 flags:0  ts: 0.80
+ret: 0 st: 0 flags:0  ts: 0.788333
 ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:288 
size:144000
-ret: 0 st: 0 flags:1  ts:-0.32
+ret: 0 st: 0 flags:1  ts:-0.317500
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 ret: 0 st: 1 flags:0  ts: 2.56
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 ret: 0 st: 1 flags:1  ts: 1.48
-ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
 ret: 0 st:-1 flags:0  ts: 0.365002
 ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.36 pos:1296000 
size:144000
 ret: 0 st:-1 flags:1  ts:-0.740831
 ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:  0 
size:144000
-ret: 0 st: 0 flags:0  ts: 2.16
+ret: 0 st: 0 flags:0  ts: 2.15
 ret: 0 st: 0 flags:1 dts: 0.96 pts: 0.96 pos:3456000 
size:144000
-ret: 0 

[FFmpeg-devel] [PATCH 09/18] lavc/dvenc: stop using DVVideoContext

2022-08-24 Thread Anton Khirnov
Move the parts of it used by the encoder into a new DVEncContext and
remove DVVideoContext.
---
 libavcodec/dv.h| 23 ---
 libavcodec/dvenc.c | 39 ---
 2 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 6430688795..859a4e6545 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -27,36 +27,13 @@
 #ifndef AVCODEC_DV_H
 #define AVCODEC_DV_H
 
-#include "avcodec.h"
 #include "dv_profile.h"
-#include "me_cmp.h"
-#include "idctdsp.h"
 
 typedef struct DVwork_chunk {
 uint16_t buf_offset;
 uint16_t mb_coordinates[5];
 } DVwork_chunk;
 
-typedef struct DVVideoContext {
-AVClass *avclass;
-const AVDVProfile *sys;
-const AVFrame   *frame;
-AVCodecContext  *avctx;
-uint8_t *buf;
-
-uint8_t dv_zigzag[2][64];
-
-void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t 
linesize);
-void (*fdct[2])(int16_t *block);
-void (*idct_put[2])(uint8_t *dest, ptrdiff_t stride, int16_t *block);
-me_cmp_func ildct_cmp;
-DVwork_chunk work_chunks[4 * 12 * 27];
-uint32_t idct_factor[2 * 4 * 16 * 64];
-IDCTDSPContext idsp;
-
-int quant_deadzone;
-} DVVideoContext;
-
 enum dv_section_type {
 dv_sect_header  = 0x1f,
 dv_sect_subcode = 0x3f,
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index c12fce9e8b..19291724e0 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -47,9 +47,26 @@
 #include "pixblockdsp.h"
 #include "put_bits.h"
 
+typedef struct DVEncContext {
+AVClass   *class;
+const AVDVProfile *sys;
+const AVFrame *frame;
+AVCodecContext*avctx;
+uint8_t   *buf;
+
+void (*get_pixels)(int16_t *block, const uint8_t *pixels, ptrdiff_t 
linesize);
+void (*fdct[2])(int16_t *block);
+
+me_cmp_func  ildct_cmp;
+DVwork_chunk work_chunks[4 * 12 * 27];
+
+int quant_deadzone;
+} DVEncContext;
+
+
 static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
-DVVideoContext *s = avctx->priv_data;
+DVEncContext *s = avctx->priv_data;
 FDCTDSPContext fdsp;
 MECmpContext mecc;
 PixblockDSPContext pdsp;
@@ -220,7 +237,7 @@ static av_always_inline PutBitContext 
*dv_encode_ac(EncBlockInfo *bi,
 return pb;
 }
 
-static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const uint8_t 
*data,
+static av_always_inline int dv_guess_dct_mode(DVEncContext *s, const uint8_t 
*data,
   ptrdiff_t linesize)
 {
 if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
@@ -368,7 +385,7 @@ static const int dv_weight_720[2][64] = {
   2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
 };
 
-static av_always_inline int dv_set_class_number_sd(DVVideoContext *s,
+static av_always_inline int dv_set_class_number_sd(DVEncContext *s,
int16_t *blk, EncBlockInfo 
*bi,
const uint8_t *zigzag_scan,
const int *weight, int bias)
@@ -452,7 +469,7 @@ static av_always_inline int 
dv_set_class_number_sd(DVVideoContext *s,
 
 /* this function just copies the DCT coefficients and performs
the initial (non-)quantization. */
-static inline void dv_set_class_number_hd(DVVideoContext *s,
+static inline void dv_set_class_number_hd(DVEncContext *s,
   int16_t *blk, EncBlockInfo *bi,
   const uint8_t *zigzag_scan,
   const int *weight, int bias)
@@ -510,7 +527,7 @@ static inline void dv_set_class_number_hd(DVVideoContext *s,
 }
 
 static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t 
*data, int linesize,
-  DVVideoContext *s, int chroma)
+  DVEncContext *s, int chroma)
 {
 LOCAL_ALIGNED_16(int16_t, blk, [64]);
 
@@ -847,7 +864,7 @@ static inline void dv_revise_cnos(uint8_t *dif, 
EncBlockInfo *blk, const AVDVPro
 
 static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
 {
-DVVideoContext *s = avctx->priv_data;
+DVEncContext *s = avctx->priv_data;
 DVwork_chunk *work_chunk = arg;
 int mb_index, i, j;
 int mb_x, mb_y, c_offset;
@@ -995,7 +1012,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, 
void *arg)
 return 0;
 }
 
-static inline int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c,
+static inline int dv_write_pack(enum dv_pack_type pack_id, DVEncContext *c,
 uint8_t *buf)
 {
 /*
@@ -1115,7 +1132,7 @@ static inline int dv_write_ssyb_id(uint8_t syb_num, 
uint8_t fr, uint8_t *buf)
 return 3;
 }
 
-static void dv_format_frame(DVVideoContext *c, uint8_t *buf)
+static void dv_format_frame(DVEncContext *c, uint8_t *buf)
 {
 int chan, i, j, 

[FFmpeg-devel] [PATCH 01/18] tests/fate/mov: add a test for dv audio demuxed through dv demuxer

2022-08-24 Thread Anton Khirnov
---
 tests/fate/mov.mak |  3 +++
 tests/ref/fate/mov-dvaudio | 31 +++
 2 files changed, 34 insertions(+)
 create mode 100644 tests/ref/fate/mov-dvaudio

diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 8a7218a215..9e8bb729a6 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -17,6 +17,7 @@ FATE_MOV = fate-mov-3elist \
fate-mov-bbi-elst-starts-b \
fate-mov-neg-firstpts-discard-frames \
fate-mov-stream-shorter-than-movie \
+   fate-mov-dvaudio \
 # FIXME: Uncomment these two lines once the test files are uploaded to the fate
 # server.
 #   fate-mov-avif-demux-still-image-1-item \
@@ -104,6 +105,8 @@ fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags 
+bitexact -i $(TARGE
 # Makes sure that no frame is dropped/duplicated with fps filter due to 
start_time / duration miscalculations.
 fate-mov-stream-shorter-than-movie: CMD = framemd5 -flags +bitexact -i 
$(TARGET_SAMPLES)/mov/mov_stream_shorter_than_movie.mov -vf fps=fps=24 -an
 
+fate-mov-dvaudio: CMD = framecrc -i 
$(TARGET_SAMPLES)/mov/qt_dv_pal_test_cut.mov -c copy -map 0:a
+
 fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets 
-print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov
 
 fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams 
-show_packets -show_frames -bitexact -print_format compact 
$(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov
diff --git a/tests/ref/fate/mov-dvaudio b/tests/ref/fate/mov-dvaudio
new file mode 100644
index 00..13e551c722
--- /dev/null
+++ b/tests/ref/fate/mov-dvaudio
@@ -0,0 +1,31 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,   -720,   -720, 1920, 7680, 0xdb43ddfd, S=1,   10
+0,   1200,   1200, 1920, 7680, 0xcd872ca8
+0,   3120,   3120, 1920, 7680, 0xa1800c21
+0,   5040,   5040, 1920, 7680, 0x87fee57a
+0,   6960,   6960, 1920, 7680, 0x2e926842
+0,   8880,   8880, 1920, 7680, 0xaf141f81
+0,  10800,  10800, 1920, 7680, 0xf0bc6ad8
+0,  12720,  12720, 1920, 7680, 0x18139585
+0,  14640,  14640, 1920, 7680, 0xadf3e99e
+0,  16560,  16560, 1920, 7680, 0xb18e02e3
+0,  18480,  18480, 1920, 7680, 0x4d8e9e72
+0,  20400,  20400, 1920, 7680, 0x27f3fd22
+0,  22320,  22320, 1920, 7680, 0xf896b2c0
+0,  24240,  24240, 1920, 7680, 0xf707d734
+0,  26160,  26160, 1920, 7680, 0xc3d4bf6a
+0,  28080,  28080, 1920, 7680, 0xaf4f92f0
+0,  3,  3, 1920, 7680, 0xf72ea49d
+0,  31920,  31920, 1920, 7680, 0xbd975338
+0,  33840,  33840, 1920, 7680, 0x50ab26db
+0,  35760,  35760, 1920, 7680, 0x2a70b14f
+0,  37680,  37680, 1920, 7680, 0x32e3ce37
+0,  39600,  39600, 1920, 7680, 0x7f5b54ec
+0,  41520,  41520, 1920, 7680, 0x2cd5478f
+0,  43440,  43440, 1920, 7680, 0x7dda4151
+0,  45360,  45360, 1920, 7680, 0x09b4886d
+0,  47280,  47280, 1920, 7680, 0x4824062e
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 04/18] lavc/dvdec: drop the only use of DVVideoContext.avctx

2022-08-24 Thread Anton Khirnov
The function gets the codec context parameter directly.
---
 libavcodec/dvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index f7423580aa..bad8419925 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -393,7 +393,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, 
void *arg)
 LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]);
 LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 
AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
 LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + 
AV_INPUT_BUFFER_PADDING_SIZE]); /* allow some slack */
-const int log2_blocksize = 3-s->avctx->lowres;
+const int log2_blocksize = 3 - avctx->lowres;
 int is_field_mode[5];
 int vs_bit_buffer_damaged = 0;
 int mb_bit_buffer_damaged[5] = {0};
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 03/18] lavf/dv: always provide avpriv_dv_* symbols

2022-08-24 Thread Anton Khirnov
They are used from libavdevice.
---
 configure|  1 +
 libavformat/Makefile |  3 +--
 libavformat/dv.c | 23 +++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ea50c94002..f4c4ab0484 100755
--- a/configure
+++ b/configure
@@ -3530,6 +3530,7 @@ gdigrab_indev_deps="CreateDIBSection"
 gdigrab_indev_extralibs="-lgdi32"
 gdigrab_indev_select="bmp_decoder"
 iec61883_indev_deps="libiec61883"
+iec61883_indev_select="dv_demuxer"
 jack_indev_deps="libjack"
 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
 kmsgrab_indev_deps="libdrm"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index f67a99f839..684bad0eb4 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -13,6 +13,7 @@ OBJS = allformats.o \
demux.o  \
demux_utils.o\
dump.o   \
+   dv.o \
format.o \
id3v1.o  \
id3v2.o  \
@@ -184,7 +185,6 @@ OBJS-$(CONFIG_DSS_DEMUXER)   += dss.o
 OBJS-$(CONFIG_DTSHD_DEMUXER) += dtshddec.o
 OBJS-$(CONFIG_DTS_DEMUXER)   += dtsdec.o rawdec.o
 OBJS-$(CONFIG_DTS_MUXER) += rawenc.o
-OBJS-$(CONFIG_DV_DEMUXER)+= dv.o
 OBJS-$(CONFIG_DV_MUXER)  += dvenc.o
 OBJS-$(CONFIG_DVBSUB_DEMUXER)+= dvbsub.o rawdec.o
 OBJS-$(CONFIG_DVBTXT_DEMUXER)+= dvbtxt.o rawdec.o
@@ -711,7 +711,6 @@ SHLIBOBJS-$(CONFIG_RTP_MUXER)+= golomb_tab.o 
jpegtables.o \
 SHLIBOBJS-$(CONFIG_SPDIF_MUXER)  += dca_sample_rate_tab.o
 
 # libavdevice dependencies
-OBJS-$(CONFIG_IEC61883_INDEV)+= dv.o
 
 # Windows resource file
 SHLIBOBJS-$(HAVE_GNU_WINDRES)+= avformatres.o
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 1dadaf6e62..24bacd5c53 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -28,6 +28,9 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "config_components.h"
+
 #include 
 #include "avformat.h"
 #include "internal.h"
@@ -40,6 +43,8 @@
 #include "dv.h"
 #include "libavutil/avassert.h"
 
+#if CONFIG_DV_DEMUXER
+
 // Must be kept in sync with AVPacket
 struct DVPacket {
 int64_t  pts;
@@ -647,3 +652,21 @@ const AVInputFormat ff_dv_demuxer = {
 .read_seek  = dv_read_seek,
 .extensions = "dv,dif",
 };
+
+#else // CONFIG_DV_DEMUXER
+DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
+{
+return NULL;
+}
+
+int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt)
+{
+return AVERROR(ENOSYS);
+}
+
+int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
+ uint8_t *buf, int buf_size, int64_t pos)
+{
+return AVERROR(ENOSYS);
+}
+#endif // CONFIG_DV_DEMUXER
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 02/18] lavf/dv: remove DVMuxContext declaration from dv.h

2022-08-24 Thread Anton Khirnov
DVMuxContext is only used inside dvenc.c, there is no reason for it to
be visible outside of that file.
---
 libavformat/dv.h| 4 +---
 libavformat/dvenc.c | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavformat/dv.h b/libavformat/dv.h
index 160c6ab873..efced6ccf0 100644
--- a/libavformat/dv.h
+++ b/libavformat/dv.h
@@ -1,5 +1,5 @@
 /*
- * General DV muxer/demuxer
+ * General DV demuxer
  * Copyright (c) 2003 Roman Shaposhnik
  *
  * Many thanks to Dan Dennedy  for providing wealth
@@ -36,6 +36,4 @@ int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *);
 int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, 
int64_t);
 void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset);
 
-typedef struct DVMuxContext DVMuxContext;
-
 #endif /* AVFORMAT_DV_H */
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 7ef9692302..429ddcb96c 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -43,7 +43,7 @@
 
 #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32-bit audio
 
-struct DVMuxContext {
+typedef struct DVMuxContext {
 AVClass  *av_class;
 const AVDVProfile*  sys;   /* current DV profile, e.g.: 525/60, 
625/50 */
 int   n_ast; /* number of stereo audio streams (up to 
2) */
@@ -55,7 +55,7 @@ struct DVMuxContext {
 int   has_video; /* frame under construction has video */
 uint8_t   frame_buf[DV_MAX_FRAME_SIZE]; /* frame under 
construction */
 AVTimecodetc;/* timecode context */
-};
+} DVMuxContext;
 
 static const int dv_aaux_packs_dist[12][9] = {
 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 06/18] lavc/dv: do not pass DVVideoContext to ff_dv_init_dynamic_tables()

2022-08-24 Thread Anton Khirnov
It only needs work_chunks from it, so pass that directly.

This is done in preparation to splitting DVVideoContext.
---
 libavcodec/dv.c| 6 +++---
 libavcodec/dv.h| 2 +-
 libavcodec/dvdec.c | 2 +-
 libavcodec/dvenc.c | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 9e05aa8927..b5e54de5dd 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -162,7 +162,7 @@ static inline void dv_calc_mb_coordinates(const AVDVProfile 
*d, int chan,
 }
 }
 
-int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const AVDVProfile *d)
+int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d)
 {
 int j, i, c, s, p;
 
@@ -174,8 +174,8 @@ int ff_dv_init_dynamic_tables(DVVideoContext *ctx, const 
AVDVProfile *d)
 p += !(j % 3);
 if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
 !(DV_PROFILE_IS_720p50(d) && s > 9)) {
-dv_calc_mb_coordinates(d, c, s, j, 
>work_chunks[i].mb_coordinates[0]);
-ctx->work_chunks[i++].buf_offset = p;
+dv_calc_mb_coordinates(d, c, s, j, 
_chunks[i].mb_coordinates[0]);
+work_chunks[i++].buf_offset = p;
 }
 p += 5;
 }
diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 2b082d0140..286b267de2 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -95,7 +95,7 @@ enum dv_pack_type {
  */
 #define DV_MAX_BPM 8
 
-int ff_dv_init_dynamic_tables(DVVideoContext *s, const AVDVProfile *d);
+int ff_dv_init_dynamic_tables(DVwork_chunk *work_chunks, const AVDVProfile *d);
 
 static inline int dv_work_pool_size(const AVDVProfile *d)
 {
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index daee2347e6..1e2c097ed0 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -626,7 +626,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 }
 
 if (sys != s->sys) {
-ret = ff_dv_init_dynamic_tables(s, sys);
+ret = ff_dv_init_dynamic_tables(s->work_chunks, sys);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error initializing the work 
tables.\n");
 return ret;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 8027feb9b3..712ca325de 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -67,7 +67,7 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 return AVERROR(EINVAL);
 }
 
-ret = ff_dv_init_dynamic_tables(s, s->sys);
+ret = ff_dv_init_dynamic_tables(s->work_chunks, s->sys);
 if (ret < 0) {
 av_log(avctx, AV_LOG_ERROR, "Error initializing work tables.\n");
 return ret;
-- 
2.35.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Add support for ICMV audio in wav

2022-08-24 Thread Paul B Mahol
will apply soon
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".