* [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
@ 2022-10-01 6:13 OvchinnikovDmitrii
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop OvchinnikovDmitrii
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: OvchinnikovDmitrii @ 2022-10-01 6:13 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: OvchinnikovDmitrii
---
libavcodec/avcodec.h | 8 ++++++++
libavcodec/codec_par.h | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7365eb5cc0..66df571afc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -585,6 +585,14 @@ typedef struct AVCodecContext {
*/
int coded_width, coded_height;
+ /**
+ * The dimensions of the crop, usually from container.
+ */
+ int crop_top;
+ int crop_left;
+ int crop_bottom;
+ int crop_right;
+
/**
* the number of pictures in a group of pictures, or 0 for intra_only
* - encoding: Set by user.
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 7660791a12..c730a79957 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
* Audio only. The channel layout and number of channels.
*/
AVChannelLayout ch_layout;
+
+ /**
+ * The dimensions of the crop, usually from container.
+ */
+ int crop_top;
+ int crop_left;
+ int crop_bottom;
+ int crop_right;
} AVCodecParameters;
/**
--
2.30.0.windows.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop
2022-10-01 6:13 [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters OvchinnikovDmitrii
@ 2022-10-01 6:13 ` OvchinnikovDmitrii
2022-10-01 7:16 ` Hendrik Leppkes
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 3/3] libavformat\matroskadec.c: crop support for matroska demuxer OvchinnikovDmitrii
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: OvchinnikovDmitrii @ 2022-10-01 6:13 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: OvchinnikovDmitrii
Support both simple and receive_frame api
The container crop information is applied additional to frame crop information
---
libavcodec/codec_par.c | 8 ++++++++
libavcodec/decode.c | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index abda649aa8..f74964a817 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -118,6 +118,10 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
par->format = codec->pix_fmt;
par->width = codec->width;
par->height = codec->height;
+ par->crop_top = codec->crop_top;
+ par->crop_left = codec->crop_left;
+ par->crop_bottom = codec->crop_bottom;
+ par->crop_right = codec->crop_right;
par->field_order = codec->field_order;
par->color_range = codec->color_range;
par->color_primaries = codec->color_primaries;
@@ -199,6 +203,10 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
codec->pix_fmt = par->format;
codec->width = par->width;
codec->height = par->height;
+ codec->crop_top = par->crop_top;
+ codec->crop_left = par->crop_left;
+ codec->crop_bottom = par->crop_bottom;
+ codec->crop_right = par->crop_right;
codec->field_order = par->field_order;
codec->color_range = par->color_range;
codec->color_primaries = par->color_primaries;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6be2d3d6ed..548225c904 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -324,6 +324,16 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
emms_c();
actual_got_frame = got_frame;
+ /* crop for simple api mode. apply additional container crop info to frame */
+ if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
+ if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){
+ frame->crop_top += avctx->crop_top;
+ frame->crop_left += avctx->crop_left;
+ frame->crop_right += avctx->crop_right;
+ frame->crop_bottom += avctx->crop_bottom;
+ }
+ }
+
if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
if (frame->flags & AV_FRAME_FLAG_DISCARD)
got_frame = 0;
@@ -707,6 +717,16 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
if (avci->buffer_frame->buf[0]) {
av_frame_move_ref(frame, avci->buffer_frame);
+
+ /* crop for receive_frame api mode. apply additional container crop info to frame */
+ if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
+ if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){
+ frame->crop_top += avctx->crop_top;
+ frame->crop_left += avctx->crop_left;
+ frame->crop_right += avctx->crop_right;
+ frame->crop_bottom += avctx->crop_bottom;
+ }
+ }
} else {
ret = decode_receive_frame_internal(avctx, frame);
if (ret < 0)
--
2.30.0.windows.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* [FFmpeg-devel] [crop support for matroska demuxer 3/3] libavformat\matroskadec.c: crop support for matroska demuxer.
2022-10-01 6:13 [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters OvchinnikovDmitrii
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop OvchinnikovDmitrii
@ 2022-10-01 6:13 ` OvchinnikovDmitrii
2022-10-01 7:06 ` [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters Hendrik Leppkes
2022-10-01 11:24 ` Timo Rothenpieler
3 siblings, 0 replies; 10+ messages in thread
From: OvchinnikovDmitrii @ 2022-10-01 6:13 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: OvchinnikovDmitrii
In webm specification, it supports cropping information. (https://www.webmproject.org/docs/container/)
In ffmpeg, the implementation of webm is a subset of matroska. In matroskadec.c, those cropping related four fields are forced to 0.
for the sample file with crop (crop_bottom =8, crop_top=crop_left=crop_right=0.)
ffmpeg.exe -i test_with_container_crop.webm -pix_fmt yuv420p -y output.yuv
original ffmpeg code - the output.yuv resolution is 1920x1088
changed code - the output.yuv resolution is 1920x1080"
---
libavformat/matroskadec.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d582f566a2..e7b00cdbe6 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -210,6 +210,10 @@ typedef struct MatroskaTrackVideo {
uint64_t pixel_width;
uint64_t pixel_height;
EbmlBin color_space;
+ uint64_t pixel_cropt;
+ uint64_t pixel_cropl;
+ uint64_t pixel_cropb;
+ uint64_t pixel_cropr;
uint64_t display_unit;
uint64_t interlaced;
uint64_t field_order;
@@ -517,10 +521,10 @@ static EbmlSyntax matroska_track_video[] = {
{ MATROSKA_ID_VIDEOALPHAMODE, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, alpha_mode), { .u = 0 } },
{ MATROSKA_ID_VIDEOCOLOR, EBML_NEST, 0, sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = matroska_track_video_color } },
{ MATROSKA_ID_VIDEOPROJECTION, EBML_NEST, 0, 0, offsetof(MatroskaTrackVideo, projection), { .n = matroska_track_video_projection } },
- { MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE },
- { MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE },
- { MATROSKA_ID_VIDEOPIXELCROPL, EBML_NONE },
- { MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE },
+ { MATROSKA_ID_VIDEOPIXELCROPT, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropt), {.u = 0 } },
+ { MATROSKA_ID_VIDEOPIXELCROPL, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropl), {.u = 0 } },
+ { MATROSKA_ID_VIDEOPIXELCROPB, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropb), {.u = 0 } },
+ { MATROSKA_ID_VIDEOPIXELCROPR, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, pixel_cropr), {.u = 0 } },
{ MATROSKA_ID_VIDEODISPLAYUNIT, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, display_unit), { .u= MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
{ MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, interlaced), { .u = MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
{ MATROSKA_ID_VIDEOFIELDORDER, EBML_UINT, 0, 0, offsetof(MatroskaTrackVideo, field_order), { .u = MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
@@ -2879,6 +2883,11 @@ static int matroska_parse_tracks(AVFormatContext *s)
st->codecpar->width = track->video.pixel_width;
st->codecpar->height = track->video.pixel_height;
+ st->codecpar->crop_top = track->video.pixel_cropt;
+ st->codecpar->crop_left = track->video.pixel_cropl;
+ st->codecpar->crop_bottom= track->video.pixel_cropb;
+ st->codecpar->crop_right = track->video.pixel_cropr;
+
if (track->video.interlaced == MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED)
st->codecpar->field_order = mkv_field_order(matroska, track->video.field_order);
else if (track->video.interlaced == MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE)
--
2.30.0.windows.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
2022-10-01 6:13 [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters OvchinnikovDmitrii
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop OvchinnikovDmitrii
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 3/3] libavformat\matroskadec.c: crop support for matroska demuxer OvchinnikovDmitrii
@ 2022-10-01 7:06 ` Hendrik Leppkes
2022-10-04 11:49 ` James Almer
2022-10-01 11:24 ` Timo Rothenpieler
3 siblings, 1 reply; 10+ messages in thread
From: Hendrik Leppkes @ 2022-10-01 7:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Oct 1, 2022 at 8:14 AM OvchinnikovDmitrii
<ovchinnikov.dmitrii@gmail.com> wrote:
>
> ---
> libavcodec/avcodec.h | 8 ++++++++
> libavcodec/codec_par.h | 8 ++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7365eb5cc0..66df571afc 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -585,6 +585,14 @@ typedef struct AVCodecContext {
> */
> int coded_width, coded_height;
>
> + /**
> + * The dimensions of the crop, usually from container.
> + */
> + int crop_top;
> + int crop_left;
> + int crop_bottom;
> + int crop_right;
> +
> /**
> * the number of pictures in a group of pictures, or 0 for intra_only
> * - encoding: Set by user.
> diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
> index 7660791a12..c730a79957 100644
> --- a/libavcodec/codec_par.h
> +++ b/libavcodec/codec_par.h
> @@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
> * Audio only. The channel layout and number of channels.
> */
> AVChannelLayout ch_layout;
> +
> + /**
> + * The dimensions of the crop, usually from container.
> + */
> + int crop_top;
> + int crop_left;
> + int crop_bottom;
> + int crop_right;
> } AVCodecParameters;
>
All of these should be size_t (and in AVCodecContext as well,
naturally), matching the type in AVFrame.
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop OvchinnikovDmitrii
@ 2022-10-01 7:16 ` Hendrik Leppkes
2022-10-04 11:35 ` Anton Khirnov
0 siblings, 1 reply; 10+ messages in thread
From: Hendrik Leppkes @ 2022-10-01 7:16 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Oct 1, 2022 at 8:14 AM OvchinnikovDmitrii
<ovchinnikov.dmitrii@gmail.com> wrote:
>
> Support both simple and receive_frame api
> The container crop information is applied additional to frame crop information
> ---
> libavcodec/codec_par.c | 8 ++++++++
> libavcodec/decode.c | 20 ++++++++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
> index abda649aa8..f74964a817 100644
> --- a/libavcodec/codec_par.c
> +++ b/libavcodec/codec_par.c
> @@ -118,6 +118,10 @@ int avcodec_parameters_from_context(AVCodecParameters *par,
> par->format = codec->pix_fmt;
> par->width = codec->width;
> par->height = codec->height;
> + par->crop_top = codec->crop_top;
> + par->crop_left = codec->crop_left;
> + par->crop_bottom = codec->crop_bottom;
> + par->crop_right = codec->crop_right;
> par->field_order = codec->field_order;
> par->color_range = codec->color_range;
> par->color_primaries = codec->color_primaries;
> @@ -199,6 +203,10 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
> codec->pix_fmt = par->format;
> codec->width = par->width;
> codec->height = par->height;
> + codec->crop_top = par->crop_top;
> + codec->crop_left = par->crop_left;
> + codec->crop_bottom = par->crop_bottom;
> + codec->crop_right = par->crop_right;
> codec->field_order = par->field_order;
> codec->color_range = par->color_range;
> codec->color_primaries = par->color_primaries;
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 6be2d3d6ed..548225c904 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -324,6 +324,16 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame,
> emms_c();
> actual_got_frame = got_frame;
>
> + /* crop for simple api mode. apply additional container crop info to frame */
> + if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
> + if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){
> + frame->crop_top += avctx->crop_top;
> + frame->crop_left += avctx->crop_left;
> + frame->crop_right += avctx->crop_right;
> + frame->crop_bottom += avctx->crop_bottom;
> + }
> + }
> +
> if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
> if (frame->flags & AV_FRAME_FLAG_DISCARD)
> got_frame = 0;
> @@ -707,6 +717,16 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>
> if (avci->buffer_frame->buf[0]) {
> av_frame_move_ref(frame, avci->buffer_frame);
> +
> + /* crop for receive_frame api mode. apply additional container crop info to frame */
> + if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
> + if (avctx->crop_top != 0 || avctx->crop_left != 0 || avctx->crop_right != 0 || avctx->crop_bottom != 0){
> + frame->crop_top += avctx->crop_top;
> + frame->crop_left += avctx->crop_left;
> + frame->crop_right += avctx->crop_right;
> + frame->crop_bottom += avctx->crop_bottom;
> + }
> + }
Somehow I don't feel like adding the two crops together is really
going to do what most users would expect to happen. It just feels
weird.
It also changes the decoder crop information, and an API user does not
get the pure information from the decoder, but rather an "interpreted"
form. As an API user, I do not get the ability here to extract the
pure decoder crop info, unless I manually null out the container info
beforehand, or subtract it again, both of which seems odd and
undesirable to me. Shouldn't I be provided with clean information, and
then I (the API user) can choose how to act?
- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
2022-10-01 6:13 [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters OvchinnikovDmitrii
` (2 preceding siblings ...)
2022-10-01 7:06 ` [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters Hendrik Leppkes
@ 2022-10-01 11:24 ` Timo Rothenpieler
2022-10-04 11:34 ` Anton Khirnov
3 siblings, 1 reply; 10+ messages in thread
From: Timo Rothenpieler @ 2022-10-01 11:24 UTC (permalink / raw)
To: ffmpeg-devel
On 01.10.2022 08:13, OvchinnikovDmitrii wrote:
> ---
> libavcodec/avcodec.h | 8 ++++++++
> libavcodec/codec_par.h | 8 ++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 7365eb5cc0..66df571afc 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -585,6 +585,14 @@ typedef struct AVCodecContext {
> */
> int coded_width, coded_height;
>
> + /**
> + * The dimensions of the crop, usually from container.
> + */
> + int crop_top;
> + int crop_left;
> + int crop_bottom;
> + int crop_right;
> +
Shouldn't these be added at the very end, to not break ABI?
I'm also not very convinced this kind of information really belongs into
AVCodecContext and codecpar.
Can't it just be frame-sidedata?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
2022-10-01 11:24 ` Timo Rothenpieler
@ 2022-10-04 11:34 ` Anton Khirnov
0 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2022-10-04 11:34 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Timo Rothenpieler (2022-10-01 13:24:26)
> On 01.10.2022 08:13, OvchinnikovDmitrii wrote:
> > ---
> > libavcodec/avcodec.h | 8 ++++++++
> > libavcodec/codec_par.h | 8 ++++++++
> > 2 files changed, 16 insertions(+)
> >
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index 7365eb5cc0..66df571afc 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -585,6 +585,14 @@ typedef struct AVCodecContext {
> > */
> > int coded_width, coded_height;
> >
> > + /**
> > + * The dimensions of the crop, usually from container.
> > + */
> > + int crop_top;
> > + int crop_left;
> > + int crop_bottom;
> > + int crop_right;
> > +
>
> Shouldn't these be added at the very end, to not break ABI?
>
yes they should
> I'm also not very convinced this kind of information really belongs into
> AVCodecContext and codecpar.
> Can't it just be frame-sidedata?
AVFrame already has fields for this, which are typically filled from
codec-level headers.
The idea here is to support container-level information, so some new
fields for lavf are certainly needed, but I'm not convinced just adding
them to AVCodecContext is the best solution. The semantics of these new
fields definitely need to be defined more precisely (like who sets them
and what does lavc do with the values).
--
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop
2022-10-01 7:16 ` Hendrik Leppkes
@ 2022-10-04 11:35 ` Anton Khirnov
0 siblings, 0 replies; 10+ messages in thread
From: Anton Khirnov @ 2022-10-04 11:35 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Hendrik Leppkes (2022-10-01 09:16:20)
> Somehow I don't feel like adding the two crops together is really
> going to do what most users would expect to happen. It just feels
> weird.
> It also changes the decoder crop information, and an API user does not
> get the pure information from the decoder, but rather an "interpreted"
> form. As an API user, I do not get the ability here to extract the
> pure decoder crop info, unless I manually null out the container info
> beforehand, or subtract it again, both of which seems odd and
> undesirable to me. Shouldn't I be provided with clean information, and
> then I (the API user) can choose how to act?
I agree, such policy decisions belong in the caller, not our libraries.
--
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
2022-10-01 7:06 ` [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters Hendrik Leppkes
@ 2022-10-04 11:49 ` James Almer
2022-10-07 15:12 ` Dmitrii Ovchinnikov
0 siblings, 1 reply; 10+ messages in thread
From: James Almer @ 2022-10-04 11:49 UTC (permalink / raw)
To: ffmpeg-devel
On 10/1/2022 4:06 AM, Hendrik Leppkes wrote:
> On Sat, Oct 1, 2022 at 8:14 AM OvchinnikovDmitrii
> <ovchinnikov.dmitrii@gmail.com> wrote:
>>
>> ---
>> libavcodec/avcodec.h | 8 ++++++++
>> libavcodec/codec_par.h | 8 ++++++++
>> 2 files changed, 16 insertions(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 7365eb5cc0..66df571afc 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -585,6 +585,14 @@ typedef struct AVCodecContext {
>> */
>> int coded_width, coded_height;
>>
>> + /**
>> + * The dimensions of the crop, usually from container.
>> + */
>> + int crop_top;
>> + int crop_left;
>> + int crop_bottom;
>> + int crop_right;
>> +
>> /**
>> * the number of pictures in a group of pictures, or 0 for intra_only
>> * - encoding: Set by user.
>> diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
>> index 7660791a12..c730a79957 100644
>> --- a/libavcodec/codec_par.h
>> +++ b/libavcodec/codec_par.h
>> @@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
>> * Audio only. The channel layout and number of channels.
>> */
>> AVChannelLayout ch_layout;
>> +
>> + /**
>> + * The dimensions of the crop, usually from container.
>> + */
>> + int crop_top;
>> + int crop_left;
>> + int crop_bottom;
>> + int crop_right;
>> } AVCodecParameters;
>>
>
> All of these should be size_t (and in AVCodecContext as well,
> naturally), matching the type in AVFrame.
IMO the AVFrame ones should have not been size_t to begin with, not just
because the actual dimensions you'll apply them to are int, but because
these fields are not arch dependent or meant for the size of some object
in memory.
>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.
2022-10-04 11:49 ` James Almer
@ 2022-10-07 15:12 ` Dmitrii Ovchinnikov
0 siblings, 0 replies; 10+ messages in thread
From: Dmitrii Ovchinnikov @ 2022-10-07 15:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Sent an updated version:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7707.
1)
>>All of these should be size_t
The field type is still "int" according to James Almer's comment.
2) I placed the fields at the very end, according to a message from Timo
Rothenpieler.
3)
>>The semantics of these new fields definitely need to be defined more
precisely
Added a flag responsible for the behavior(enum
CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;).
When set to 1 (the default), libavcodec will apply container cropping
to codec cropping additionally.
When set to 2, libavcodec will use container cropping to overwrite
codec cropping (the final cropping uses container cropping parameters)
When set to 0, libavcodec will ignore container cropping parameters
(the final cropping uses codec cropping parameters)This field works with
"apply_cropping".
Only if apply_cropping is 1, this field works
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-10-07 15:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 6:13 [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters OvchinnikovDmitrii
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 2/3] libavcodec: Public code to support container crop OvchinnikovDmitrii
2022-10-01 7:16 ` Hendrik Leppkes
2022-10-04 11:35 ` Anton Khirnov
2022-10-01 6:13 ` [FFmpeg-devel] [crop support for matroska demuxer 3/3] libavformat\matroskadec.c: crop support for matroska demuxer OvchinnikovDmitrii
2022-10-01 7:06 ` [FFmpeg-devel] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters Hendrik Leppkes
2022-10-04 11:49 ` James Almer
2022-10-07 15:12 ` Dmitrii Ovchinnikov
2022-10-01 11:24 ` Timo Rothenpieler
2022-10-04 11:34 ` Anton Khirnov
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git