[FFmpeg-cvslog] Merge commit '52627248e49e58eb4b78e4fcda90a64f4c476ea3'

James Almer git at videolan.org
Mon May 8 21:46:55 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon May  8 13:08:02 2017 -0300| [a47bd5d77e3f1dd8bb3d4ba0955bd7b1323c7d83] | committer: James Almer

Merge commit '52627248e49e58eb4b78e4fcda90a64f4c476ea3'

* commit '52627248e49e58eb4b78e4fcda90a64f4c476ea3':
  frame: add a cropping rectangle to AVFrame

Merged-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a47bd5d77e3f1dd8bb3d4ba0955bd7b1323c7d83
---

 doc/APIchanges      |  4 ++++
 libavutil/frame.c   |  4 ++++
 libavutil/frame.h   | 28 +++++++++++++++++++++++++++-
 libavutil/version.h |  3 ++-
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 01c55a1ed0..ae5490b4c2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-xx-xx - xxxxxxx - lavu 55.62.100 / 55.30.0 - frame.h
+  Add AVFrame.crop_left/right/top/bottom fields for attaching cropping
+  information to video frames.
+
 2017-xx-xx - xxxxxxxxxx
   Change av_sha_update(), av_sha512_update() and av_md5_sum()/av_md5_update() length
   parameter type to size_t at next major bump.
diff --git a/libavutil/frame.c b/libavutil/frame.c
index dd12c5549c..24d5d5f184 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -297,6 +297,10 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
     dst->key_frame              = src->key_frame;
     dst->pict_type              = src->pict_type;
     dst->sample_aspect_ratio    = src->sample_aspect_ratio;
+    dst->crop_top               = src->crop_top;
+    dst->crop_bottom            = src->crop_bottom;
+    dst->crop_left              = src->crop_left;
+    dst->crop_right             = src->crop_right;
     dst->pts                    = src->pts;
     dst->repeat_pict            = src->repeat_pict;
     dst->interlaced_frame       = src->interlaced_frame;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 4d8c1bed4f..26261d7e40 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -25,6 +25,7 @@
 #ifndef AVUTIL_FRAME_H
 #define AVUTIL_FRAME_H
 
+#include <stddef.h>
 #include <stdint.h>
 
 #include "avutil.h"
@@ -240,9 +241,18 @@ typedef struct AVFrame {
     uint8_t **extended_data;
 
     /**
-     * width and height of the video frame
+     * @name Video dimensions
+     * Video frames only. The coded dimensions (in pixels) of the video frame,
+     * i.e. the size of the rectangle that contains some well-defined values.
+     *
+     * @note The part of the frame intended for display/presentation is further
+     * restricted by the @ref cropping "Cropping rectangle".
+     * @{
      */
     int width, height;
+    /**
+     * @}
+     */
 
     /**
      * number of audio samples (per channel) described by this frame
@@ -530,6 +540,22 @@ typedef struct AVFrame {
      * purpose.
      */
     AVBufferRef *opaque_ref;
+
+    /**
+     * @anchor cropping
+     * @name Cropping
+     * Video frames only. The number of pixels to discard from the the
+     * top/bottom/left/right border of the frame to obtain the sub-rectangle of
+     * the frame intended for presentation.
+     * @{
+     */
+    size_t crop_top;
+    size_t crop_bottom;
+    size_t crop_left;
+    size_t crop_right;
+    /**
+     * @}
+     */
 } AVFrame;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index e7a657971f..6762bf300a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -78,8 +78,9 @@
  * @{
  */
 
+
 #define LIBAVUTIL_VERSION_MAJOR  55
-#define LIBAVUTIL_VERSION_MINOR  61
+#define LIBAVUTIL_VERSION_MINOR  62
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \


======================================================================

diff --cc doc/APIchanges
index 01c55a1ed0,ba137650b6..ae5490b4c2
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@@ -15,31 -13,29 +15,35 @@@ libavutil:     2015-08-2
  
  API changes, most recent first:
  
 -2016-xx-xx - xxxxxxx - lavu 55.30.0 - frame.h
++2017-xx-xx - xxxxxxx - lavu 55.62.100 / 55.30.0 - frame.h
+   Add AVFrame.crop_left/right/top/bottom fields for attaching cropping
+   information to video frames.
+ 
 -2016-xx-xx - xxxxxxx
 -  Change av_sha_update() and av_md5_sum()/av_md5_update() length
 +2017-xx-xx - xxxxxxxxxx
 +  Change av_sha_update(), av_sha512_update() and av_md5_sum()/av_md5_update() length
    parameter type to size_t at next major bump.
  
 -2016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h
 -  Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
 -  information from containers.
 +2017-05-05 - xxxxxxxxxx - lavc 57.94.100 - avcodec.h
 +  The cuvid decoders now support AVCodecContext.hw_device_ctx, which removes
 +  the requirement to set an incomplete AVCodecContext.hw_frames_ctx only to
 +  set the Cuda device handle.
  
 -2016-xx-xx - xxxxxxx - lavu 55.30.0 - spherical.h
 -  Add AV_FRAME_DATA_SPHERICAL value, av_spherical_alloc() API and
 -  AVSphericalMapping type to export and describe spherical video properties.
 +2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h
 +  Add av_strireplace().
  
 -2016-xx-xx - xxxxxxx - lavf 57.10.0 - avformat.h
 -  Add av_stream_add_side_data().
 +2016-04-06 - 157e57a181 - lavc 57.92.100 - avcodec.h
 +  Add AV_PKT_DATA_CONTENT_LIGHT_LEVEL packet side data.
  
 -2016-xx-xx - xxxxxxx - lavu 55.28.0 - pixfmt.h
 -  Add AV_PIX_FMT_GRAY12(LE/BE).
 +2016-04-06 - b378f5bd64 - lavu 55.60.100 - mastering_display_metadata.h
 +  Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc()
 +  and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata
 +  type to export content light level video properties.
 +
 +2017-03-31 - 9033e8723c - lavu 55.57.100 - spherical.h
 +  Add av_spherical_projection_name().
 +  Add av_spherical_from_name().
  
 -2016-xx-xx - xxxxxxx - lavu 55.27.0 - hwcontext.h
 +2017-03-30 - 4cda23f1f1 - lavu 55.53.100 / 55.27.0 - hwcontext.h
    Add av_hwframe_map() and associated AV_HWFRAME_MAP_* flags.
    Add av_hwframe_ctx_create_derived().
  
diff --cc libavutil/frame.c
index dd12c5549c,aafaa57d8b..24d5d5f184
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@@ -290,101 -196,6 +290,105 @@@ int av_frame_get_buffer(AVFrame *frame
      return AVERROR(EINVAL);
  }
  
 +static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
 +{
 +    int i;
 +
 +    dst->key_frame              = src->key_frame;
 +    dst->pict_type              = src->pict_type;
 +    dst->sample_aspect_ratio    = src->sample_aspect_ratio;
++    dst->crop_top               = src->crop_top;
++    dst->crop_bottom            = src->crop_bottom;
++    dst->crop_left              = src->crop_left;
++    dst->crop_right             = src->crop_right;
 +    dst->pts                    = src->pts;
 +    dst->repeat_pict            = src->repeat_pict;
 +    dst->interlaced_frame       = src->interlaced_frame;
 +    dst->top_field_first        = src->top_field_first;
 +    dst->palette_has_changed    = src->palette_has_changed;
 +    dst->sample_rate            = src->sample_rate;
 +    dst->opaque                 = src->opaque;
 +#if FF_API_PKT_PTS
 +FF_DISABLE_DEPRECATION_WARNINGS
 +    dst->pkt_pts                = src->pkt_pts;
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif
 +    dst->pkt_dts                = src->pkt_dts;
 +    dst->pkt_pos                = src->pkt_pos;
 +    dst->pkt_size               = src->pkt_size;
 +    dst->pkt_duration           = src->pkt_duration;
 +    dst->reordered_opaque       = src->reordered_opaque;
 +    dst->quality                = src->quality;
 +    dst->best_effort_timestamp  = src->best_effort_timestamp;
 +    dst->coded_picture_number   = src->coded_picture_number;
 +    dst->display_picture_number = src->display_picture_number;
 +    dst->flags                  = src->flags;
 +    dst->decode_error_flags     = src->decode_error_flags;
 +    dst->color_primaries        = src->color_primaries;
 +    dst->color_trc              = src->color_trc;
 +    dst->colorspace             = src->colorspace;
 +    dst->color_range            = src->color_range;
 +    dst->chroma_location        = src->chroma_location;
 +
 +    av_dict_copy(&dst->metadata, src->metadata, 0);
 +
 +#if FF_API_ERROR_FRAME
 +FF_DISABLE_DEPRECATION_WARNINGS
 +    memcpy(dst->error, src->error, sizeof(dst->error));
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif
 +
 +    for (i = 0; i < src->nb_side_data; i++) {
 +        const AVFrameSideData *sd_src = src->side_data[i];
 +        AVFrameSideData *sd_dst;
 +        if (   sd_src->type == AV_FRAME_DATA_PANSCAN
 +            && (src->width != dst->width || src->height != dst->height))
 +            continue;
 +        if (force_copy) {
 +            sd_dst = av_frame_new_side_data(dst, sd_src->type,
 +                                            sd_src->size);
 +            if (!sd_dst) {
 +                wipe_side_data(dst);
 +                return AVERROR(ENOMEM);
 +            }
 +            memcpy(sd_dst->data, sd_src->data, sd_src->size);
 +        } else {
 +            sd_dst = frame_new_side_data(dst, sd_src->type, av_buffer_ref(sd_src->buf));
 +            if (!sd_dst) {
 +                wipe_side_data(dst);
 +                return AVERROR(ENOMEM);
 +            }
 +        }
 +        av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
 +    }
 +
 +#if FF_API_FRAME_QP
 +FF_DISABLE_DEPRECATION_WARNINGS
 +    dst->qscale_table = NULL;
 +    dst->qstride      = 0;
 +    dst->qscale_type  = 0;
 +    av_buffer_unref(&dst->qp_table_buf);
 +    if (src->qp_table_buf) {
 +        dst->qp_table_buf = av_buffer_ref(src->qp_table_buf);
 +        if (dst->qp_table_buf) {
 +            dst->qscale_table = dst->qp_table_buf->data;
 +            dst->qstride      = src->qstride;
 +            dst->qscale_type  = src->qscale_type;
 +        }
 +    }
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif
 +
 +    av_buffer_unref(&dst->opaque_ref);
 +    if (src->opaque_ref) {
 +        dst->opaque_ref = av_buffer_ref(src->opaque_ref);
 +        if (!dst->opaque_ref)
 +            return AVERROR(ENOMEM);
 +    }
 +
 +    return 0;
 +}
 +
  int av_frame_ref(AVFrame *dst, const AVFrame *src)
  {
      int i, ret = 0;
diff --cc libavutil/frame.h
index 4d8c1bed4f,c718f7bd62..26261d7e40
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@@ -521,15 -381,20 +531,31 @@@ typedef struct AVFrame 
      AVBufferRef *hw_frames_ctx;
  
      /**
 +     * AVBufferRef for free use by the API user. FFmpeg will never check the
 +     * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
 +     * the frame is unreferenced. av_frame_copy_props() calls create a new
 +     * reference with av_buffer_ref() for the target frame's opaque_ref field.
 +     *
 +     * This is unrelated to the opaque field, although it serves a similar
 +     * purpose.
 +     */
 +    AVBufferRef *opaque_ref;
++
++    /**
+      * @anchor cropping
+      * @name Cropping
+      * Video frames only. The number of pixels to discard from the the
+      * top/bottom/left/right border of the frame to obtain the sub-rectangle of
+      * the frame intended for presentation.
+      * @{
+      */
+     size_t crop_top;
+     size_t crop_bottom;
+     size_t crop_left;
+     size_t crop_right;
+     /**
+      * @}
+      */
  } AVFrame;
  
  /**
diff --cc libavutil/version.h
index e7a657971f,7856a0acc3..6762bf300a
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@@ -78,9 -53,9 +78,10 @@@
   * @{
   */
  
 -#define LIBAVUTIL_VERSION_MAJOR 55
 -#define LIBAVUTIL_VERSION_MINOR 30
 -#define LIBAVUTIL_VERSION_MICRO  0
++
 +#define LIBAVUTIL_VERSION_MAJOR  55
- #define LIBAVUTIL_VERSION_MINOR  61
++#define LIBAVUTIL_VERSION_MINOR  62
 +#define LIBAVUTIL_VERSION_MICRO 100
  
  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                 LIBAVUTIL_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list