diff mbox series

[FFmpeg-devel,05/44] avformat/mux: Move ff_choose_chroma_location to mxfenc, its only user

Message ID AS8PR01MB7944BE275F4E17402C83FA808FC49@AS8PR01MB7944.eurprd01.prod.exchangelabs.com
State Accepted
Commit 5130bbb7efe1125c515eddedc0985fa9b6e5d731
Headers show
Series [FFmpeg-devel] lib*/version: Move library version functions into files of their own | expand

Commit Message

Andreas Rheinhardt May 7, 2022, 11:27 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/internal.h |  5 -----
 libavformat/mux.c      | 31 -------------------------------
 libavformat/mxfenc.c   | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 37 deletions(-)

Comments

Tomas Härdin May 10, 2022, 7:25 a.m. UTC | #1
lör 2022-05-07 klockan 13:27 +0200 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/internal.h |  5 -----
>  libavformat/mux.c      | 31 -------------------------------
>  libavformat/mxfenc.c   | 31 ++++++++++++++++++++++++++++++-
>  3 files changed, 30 insertions(+), 37 deletions(-)
> 
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 715e3ce33f..5e84942fb9 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -765,11 +765,6 @@ int ff_is_intra_only(enum AVCodecID id);
>   */
>  enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int
> sflags);
>  
> -/**
> - * Chooses a timebase for muxing the specified stream.
> - */

What's up with this comment?

Rest looks OK

/Tomas
Andreas Rheinhardt May 10, 2022, 7:29 a.m. UTC | #2
Tomas Härdin:
> lör 2022-05-07 klockan 13:27 +0200 skrev Andreas Rheinhardt:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavformat/internal.h |  5 -----
>>  libavformat/mux.c      | 31 -------------------------------
>>  libavformat/mxfenc.c   | 31 ++++++++++++++++++++++++++++++-
>>  3 files changed, 30 insertions(+), 37 deletions(-)
>>
>> diff --git a/libavformat/internal.h b/libavformat/internal.h
>> index 715e3ce33f..5e84942fb9 100644
>> --- a/libavformat/internal.h
>> +++ b/libavformat/internal.h
>> @@ -765,11 +765,6 @@ int ff_is_intra_only(enum AVCodecID id);
>>   */
>>  enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int
>> sflags);
>>  
>> -/**
>> - * Chooses a timebase for muxing the specified stream.
>> - */
> 
> What's up with this comment?
> 

It's wrong. It seems to have been duplicated from ff_choose_timebase. Or
maybe there was a merge/rebase error? I didn't check where it came from,
I just removed it.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 715e3ce33f..5e84942fb9 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -765,11 +765,6 @@  int ff_is_intra_only(enum AVCodecID id);
  */
 enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
 
-/**
- * Chooses a timebase for muxing the specified stream.
- */
-enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st);
-
 /**
  * Generate standard extradata for AVC-Intra based on width/height and field
  * order.
diff --git a/libavformat/mux.c b/libavformat/mux.c
index cfcfa600df..11b0cb1307 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -28,7 +28,6 @@ 
 #include "libavcodec/packet_internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/dict.h"
-#include "libavutil/pixdesc.h"
 #include "libavutil/timestamp.h"
 #include "libavutil/avassert.h"
 #include "libavutil/internal.h"
@@ -89,36 +88,6 @@  static void frac_add(FFFrac *f, int64_t incr)
     f->num = num;
 }
 
-enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st)
-{
-    AVCodecParameters *par = st->codecpar;
-    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(par->format);
-
-    if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
-        return par->chroma_location;
-
-    if (pix_desc) {
-        if (pix_desc->log2_chroma_h == 0) {
-            return AVCHROMA_LOC_TOPLEFT;
-        } else if (pix_desc->log2_chroma_w == 1 && pix_desc->log2_chroma_h == 1) {
-            if (par->field_order == AV_FIELD_UNKNOWN || par->field_order == AV_FIELD_PROGRESSIVE) {
-                switch (par->codec_id) {
-                case AV_CODEC_ID_MJPEG:
-                case AV_CODEC_ID_MPEG1VIDEO: return AVCHROMA_LOC_CENTER;
-                }
-            }
-            if (par->field_order == AV_FIELD_UNKNOWN || par->field_order != AV_FIELD_PROGRESSIVE) {
-                switch (par->codec_id) {
-                case AV_CODEC_ID_MPEG2VIDEO: return AVCHROMA_LOC_LEFT;
-                }
-            }
-        }
-    }
-
-    return AVCHROMA_LOC_UNSPECIFIED;
-
-}
-
 int avformat_alloc_output_context2(AVFormatContext **avctx, const AVOutputFormat *oformat,
                                    const char *format, const char *filename)
 {
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2061b2eede..7041659143 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2496,6 +2496,35 @@  static int mxf_init_timecode(AVFormatContext *s, AVStream *st, AVRational tbc)
         return av_timecode_init(&mxf->tc, av_inv_q(tbc), 0, 0, s);
 }
 
+static enum AVChromaLocation choose_chroma_location(AVFormatContext *s, AVStream *st)
+{
+    AVCodecParameters *par = st->codecpar;
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(par->format);
+
+    if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
+        return par->chroma_location;
+
+    if (pix_desc) {
+        if (pix_desc->log2_chroma_h == 0) {
+            return AVCHROMA_LOC_TOPLEFT;
+        } else if (pix_desc->log2_chroma_w == 1 && pix_desc->log2_chroma_h == 1) {
+            if (par->field_order == AV_FIELD_UNKNOWN || par->field_order == AV_FIELD_PROGRESSIVE) {
+                switch (par->codec_id) {
+                case AV_CODEC_ID_MJPEG:
+                case AV_CODEC_ID_MPEG1VIDEO: return AVCHROMA_LOC_CENTER;
+                }
+            }
+            if (par->field_order == AV_FIELD_UNKNOWN || par->field_order != AV_FIELD_PROGRESSIVE) {
+                switch (par->codec_id) {
+                case AV_CODEC_ID_MPEG2VIDEO: return AVCHROMA_LOC_LEFT;
+                }
+            }
+        }
+    }
+
+    return AVCHROMA_LOC_UNSPECIFIED;
+}
+
 static int mxf_init(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
@@ -2544,7 +2573,7 @@  static int mxf_init(AVFormatContext *s)
                 sc->h_chroma_sub_sample = 1 << pix_desc->log2_chroma_w;
                 sc->v_chroma_sub_sample = 1 << pix_desc->log2_chroma_h;
             }
-            switch (ff_choose_chroma_location(s, st)) {
+            switch (choose_chroma_location(s, st)) {
             case AVCHROMA_LOC_TOPLEFT: sc->color_siting = 0; break;
             case AVCHROMA_LOC_LEFT:    sc->color_siting = 6; break;
             case AVCHROMA_LOC_TOP:     sc->color_siting = 1; break;