Merge commit '271ce76d317c5432e151216cf23f12b77ed6cb7e'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 30 Jun 2015 20:51:19 +0000 (22:51 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 30 Jun 2015 20:54:33 +0000 (22:54 +0200)
* commit '271ce76d317c5432e151216cf23f12b77ed6cb7e':
  h264: Parse registered data SEI message and AFD value

Conflicts:
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_sei.c
libavcodec/version.h

See: d6e95669496a89d186f923c34bcaf7d86b7cd59c
See: 22291c372fa703242e8429bed61700ba81258f19
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h264.c
libavcodec/h264.h
libavcodec/h264_sei.c
libavcodec/version.h

@@@ -606,9 -574,6 +606,8 @@@ static int h264_init_context(AVCodecCon
      h->x264_build            = -1;
      h->recovery_frame        = -1;
      h->frame_recovered       = 0;
-     h->has_afd               = 0;
 +    h->prev_frame_num        = -1;
 +    h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
  
      h->next_outputed_poc = INT_MIN;
      for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
@@@ -863,25 -814,24 +862,26 @@@ static void decode_postinit(H264Contex
          AVFrameSideData *rotation = av_frame_new_side_data(cur->f,
                                                             AV_FRAME_DATA_DISPLAYMATRIX,
                                                             sizeof(int32_t) * 9);
 -        if (!rotation)
 -            return;
 -
 -        av_display_rotation_set((int32_t *)rotation->data, angle);
 -        av_display_matrix_flip((int32_t *)rotation->data,
 -                               h->sei_hflip, h->sei_vflip);
 +        if (rotation) {
 +            av_display_rotation_set((int32_t *)rotation->data, angle);
 +            av_display_matrix_flip((int32_t *)rotation->data,
 +                                   h->sei_hflip, h->sei_vflip);
 +        }
      }
  
-     if (h->has_afd) {
-         AVFrameSideData *sd =
-             av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, 1);
+     if (h->sei_reguserdata_afd_present) {
+         AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD,
+                                                      sizeof(uint8_t));
 -        if (!sd)
 -            return;
 -        *sd->data = h->active_format_description;
 -        h->sei_reguserdata_afd_present = 0;
 +        if (sd) {
-             *sd->data   = h->afd;
-             h->has_afd = 0;
++            *sd->data = h->active_format_description;
++            h->sei_reguserdata_afd_present = 0;
 +        }
      }
  
 +    cur->mmco_reset = h->mmco_reset;
 +    h->mmco_reset = 0;
 +
      // FIXME do something with unavailable reference frames
  
      /* Sort B-frames into display order */
@@@ -778,15 -728,7 +784,12 @@@ typedef struct H264Context 
  
      int frame_recovered;    ///< Initial frame has been completely recovered
  
 -    /* for frame threading, this is set to 1
 +    int has_recovery_point;
 +
 +    int missing_fields;
 +
-     uint8_t afd;
-     int has_afd;
 +
 +/* for frame threading, this is set to 1
       * after finish_setup() has been called, so we cannot modify
       * some context properties (which are supposed to stay constant between
       * slices) anymore */
@@@ -108,39 -103,41 +109,47 @@@ static int decode_picture_timing(H264Co
      return 0;
  }
  
- static int decode_user_data_itu_t_t35(H264Context *h, int size)
+ static int decode_registered_user_data(H264Context *h, int size)
  {
+     uint32_t country_code;
      uint32_t user_identifier;
 +    int dtg_active_format;
+     int flag;
  
      if (size < 7)
-         return -1;
+         return AVERROR_INVALIDDATA;
      size -= 7;
  
-     skip_bits(&h->gb, 8);   // country_code
-     skip_bits(&h->gb, 16);  // provider_code
+     country_code = get_bits(&h->gb, 8); // itu_t_t35_country_code
+     if (country_code == 0xFF) {
+         skip_bits(&h->gb, 8);           // itu_t_t35_country_code_extension_byte
+         size--;
+     }
+     /* itu_t_t35_payload_byte follows */
+     skip_bits(&h->gb, 8);              // terminal provider code
+     skip_bits(&h->gb, 8);              // terminal provider oriented code
      user_identifier = get_bits_long(&h->gb, 32);
  
      switch (user_identifier) {
-         case 0x44544731:    // "DTG1" - AFD_data
-             if (size < 1)
-                 return -1;
-             skip_bits(&h->gb, 1);
-             if (get_bits(&h->gb, 1)) {
-                 skip_bits(&h->gb, 6);
-                 if (size < 2)
-                     return -1;
-                 skip_bits(&h->gb, 4);
-                 dtg_active_format = get_bits(&h->gb, 4);
+         case MKBETAG('D', 'T', 'G', '1'):       // afd_data
+             if (size-- < 1)
+                 return AVERROR_INVALIDDATA;
+             skip_bits(&h->gb, 1);               // 0
+             flag = get_bits(&h->gb, 1);         // active_format_flag
+             skip_bits(&h->gb, 6);               // reserved
+             if (flag) {
+                 if (size-- < 1)
+                     return AVERROR_INVALIDDATA;
+                 skip_bits(&h->gb, 4);           // reserved
+                 h->active_format_description   = get_bits(&h->gb, 4);
+                 h->sei_reguserdata_afd_present = 1;
 +#if FF_API_AFD
 +FF_DISABLE_DEPRECATION_WARNINGS
-                 h->avctx->dtg_active_format = dtg_active_format;
++                h->avctx->dtg_active_format = h->active_format_description;
 +FF_ENABLE_DEPRECATION_WARNINGS
 +#endif /* FF_API_AFD */
-                 h->has_afd = 1;
-                 h->afd     = dtg_active_format;
-             } else {
-                 skip_bits(&h->gb, 6);
              }
              break;
          default:
@@@ -29,8 -29,8 +29,8 @@@
  #include "libavutil/version.h"
  
  #define LIBAVCODEC_VERSION_MAJOR 56
 -#define LIBAVCODEC_VERSION_MINOR 29
 -#define LIBAVCODEC_VERSION_MICRO  1
 +#define LIBAVCODEC_VERSION_MINOR  45
- #define LIBAVCODEC_VERSION_MICRO 101
++#define LIBAVCODEC_VERSION_MICRO 102
  
  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                 LIBAVCODEC_VERSION_MINOR, \