diff --git a/mythtv/libs/libmythtv/mpeg/H264Parser.cpp b/mythtv/libs/libmythtv/mpeg/H264Parser.cpp
old mode 100644
new mode 100755
index ac805e7..cabdfc5
--- a/mythtv/libs/libmythtv/mpeg/H264Parser.cpp
+++ b/mythtv/libs/libmythtv/mpeg/H264Parser.cpp
@@ -92,6 +92,8 @@ static const float eps = 1E-5;
 
 H264Parser::H264Parser(void)
 {
+    rbsp_buffer      = NULL;
+    rbsp_buffer_size = 0;
     Reset();
     I_is_keyframe = true;
     memset(&gb, 0, sizeof(gb));
@@ -183,28 +185,28 @@ bool H264Parser::new_AU(void)
       one or more of the following ways.
 
       - frame_num differs in value. The value of frame_num used to
-      test this condition is the value of frame_num that appears in
-      the syntax of the slice header, regardless of whether that value
-      is inferred to have been equal to 0 for subsequent use in the
-      decoding process due to the presence of
-      memory_management_control_operation equal to 5.
+        test this condition is the value of frame_num that appears in
+        the syntax of the slice header, regardless of whether that value
+        is inferred to have been equal to 0 for subsequent use in the
+        decoding process due to the presence of
+        memory_management_control_operation equal to 5.
           Note: If the current picture is an IDR picture FrameNum and
           PrevRefFrameNum are set equal to 0.
       - pic_parameter_set_id differs in value.
       - field_pic_flag differs in value.
       - bottom_field_flag is present in both and differs in value.
-      - nal_ref_idc differs in value with one of the nal_ref_idc values
-      being equal to 0.
+      - nal_ref_idc differs in value with one of the nal_ref_idc
+        values being equal to 0.
       - pic_order_cnt_type is equal to 0 for both and either
-      pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom
-      differs in value.
+        pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom
+        differs in value.
       - pic_order_cnt_type is equal to 1 for both and either
-      delta_pic_order_cnt[0] differs in value, or
-      delta_pic_order_cnt[1] differs in value.
+        delta_pic_order_cnt[0] differs in value, or
+        delta_pic_order_cnt[1] differs in value.
       - nal_unit_type differs in value with one of the nal_unit_type values
-      being equal to 5.
+        being equal to 5.
       - nal_unit_type is equal to 5 for both and idr_pic_id differs in
-      value.
+        value.
 
       NOTE – Some of the VCL NAL units in redundant coded pictures or some
       non-VCL NAL units (e.g. an access unit delimiter NAL unit) may also
@@ -230,6 +232,9 @@ bool H264Parser::new_AU(void)
         else if ((bottom_field_flag != -1 && prev_bottom_field_flag != -1) &&
                  bottom_field_flag != prev_bottom_field_flag)
             result = true;
+        else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) &&
+                 nal_ref_idc != prev_nal_ref_idc)
+            result = true;
         else if ((pic_order_cnt_type == 0 && prev_pic_order_cnt_type == 0) &&
                  (pic_order_cnt_lsb != prev_pic_order_cnt_lsb ||
                   delta_pic_order_cnt_bottom !=
@@ -253,6 +258,7 @@ bool H264Parser::new_AU(void)
     prev_pic_parameter_set_id = pic_parameter_set_id;
     prev_field_pic_flag = field_pic_flag;
     prev_bottom_field_flag = bottom_field_flag;
+    prev_nal_ref_idc = nal_ref_idc;
     prev_pic_order_cnt_lsb = pic_order_cnt_lsb;
     prev_delta_pic_order_cnt_bottom = delta_pic_order_cnt_bottom;
     prev_delta_pic_order_cnt[0] = delta_pic_order_cnt[0];
@@ -263,6 +269,44 @@ bool H264Parser::new_AU(void)
     return result;
 }
 
+uint32_t H264Parser::load_rbsp(const uint8_t *byteP, uint32_t byte_count)
+{
+    uint32_t rbsp_index        = 0;
+    uint32_t consecutive_zeros = 0;
+
+    if(rbsp_buffer_size < byte_count)
+    {
+        delete [] rbsp_buffer;
+        rbsp_buffer_size = 0;
+
+        rbsp_buffer = new uint8_t[byte_count];
+        if(rbsp_buffer == NULL)
+            return 0;
+
+        rbsp_buffer_size = byte_count;
+    }
+
+    /* From rbsp while we have data and we don't run into a
+     * new start code */
+    while(byte_count && (consecutive_zeros < 2 || *byteP != 0x01))
+    {
+        /* Copy the byte into the rbsp, unless it
+         * is the 0x03 in a 0x000003 */
+        if(consecutive_zeros < 2 || *byteP != 0x03)
+            rbsp_buffer[rbsp_index++] = *byteP;
+
+        if(*byteP == 0)
+            consecutive_zeros += 1;
+        else
+            consecutive_zeros = 0;
+
+        byteP += 1;
+        byte_count -= 1;
+    }
+
+    return rbsp_index;
+}
+
 uint32_t H264Parser::addBytes(const uint8_t  *bytes,
                               const uint32_t  byte_count,
                               const uint64_t  stream_offset)
@@ -306,13 +350,17 @@ uint32_t H264Parser::addBytes(const uint8_t  *bytes,
             if (nal_unit_type == SPS || nal_unit_type == PPS ||
                 nal_unit_type == SEI || NALisSlice(nal_unit_type))
             {
+                uint32_t rbsp_size;
+
+                rbsp_size = load_rbsp(byteP, endP - byteP);
+
                 /*
                   bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE
                   bytes larger then the actual read bits
                 */
-                if (byteP + 1 + FF_INPUT_BUFFER_PADDING_SIZE < endP)
+                if (FF_INPUT_BUFFER_PADDING_SIZE <= rbsp_size)
                 {
-                    init_get_bits(&gb, byteP, 8 * (endP - byteP));
+                    init_get_bits(&gb, rbsp_buffer, 8 * rbsp_size);
 
                     if (nal_unit_type == SEI)
                     {
@@ -335,8 +383,6 @@ uint32_t H264Parser::addBytes(const uint8_t  *bytes,
                         if (new_AU())
                             set_AU_pending(stream_offset);
                     }
-
-                    byteP += (get_bits_count(&gb) / 8);
                 }
             }
             else if (!AU_pending)
@@ -348,12 +394,6 @@ uint32_t H264Parser::addBytes(const uint8_t  *bytes,
                     AU_pending = true;
                     AU_offset = stream_offset;
                 }
-                else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) &&
-                         nal_ref_idc != prev_nal_ref_idc)
-                {
-                    AU_pending = true;
-                    AU_offset = stream_offset;
-                }
             }
 
             if (AU_pending && NALisSlice(nal_unit_type))
@@ -378,8 +418,6 @@ uint32_t H264Parser::addBytes(const uint8_t  *bytes,
             else
                 on_frame = on_key_frame = false;
 
-            prev_nal_ref_idc = nal_ref_idc;
-
             return byteP - bytes;
         }
     }
@@ -600,7 +638,14 @@ void H264Parser::decode_SPS(GetBitContext * gb)
         {
             for (int idx = 0; idx < ((chroma_format_idc != 3) ? 8 : 12); ++idx)
             {
-                get_bits1(gb);  // scaling_list
+                if(get_bits1(gb)) // Scaling list presnent
+                {
+                    int sl_n = ((idx < 6) ? 16 : 64);
+                    for(int sl_i = 0; sl_i < sl_n; sl_i++)
+                    {
+                        get_se_golomb(gb);
+                    }
+                }
             }
         }
     }
@@ -1015,7 +1060,7 @@ void H264Parser::vui_parameters(GetBitContext * gb)
 
 uint H264Parser::frameRate(void) const
 {
-    uint64_t	num;
+    uint64_t    num;
     uint64_t    fps;
 
     num   = 500 * (uint64_t)timeScale; /* 1000 * 0.5 */
diff --git a/mythtv/libs/libmythtv/mpeg/H264Parser.h b/mythtv/libs/libmythtv/mpeg/H264Parser.h
index 2117a96..d737741 100644
--- a/mythtv/libs/libmythtv/mpeg/H264Parser.h
+++ b/mythtv/libs/libmythtv/mpeg/H264Parser.h
@@ -101,7 +101,7 @@ class H264Parser {
     };
 
     H264Parser(void);
-    ~H264Parser(void) {;}
+    ~H264Parser(void) {delete [] rbsp_buffer;}
 
     uint32_t addBytes(const uint8_t  *bytes,
                       const uint32_t  byte_count,
@@ -168,6 +168,7 @@ class H264Parser {
         }
 
     bool new_AU(void);
+    uint32_t load_rbsp(const uint8_t *byteP, uint32_t byte_count);
     bool decode_Header(GetBitContext *gb);
     void decode_SPS(GetBitContext *gb);
     void decode_PPS(GetBitContext * gb);
@@ -181,6 +182,8 @@ class H264Parser {
     bool       I_is_keyframe;
 
     uint32_t   sync_accumulator;
+    uint8_t   *rbsp_buffer;
+    uint32_t   rbsp_buffer_size;
     GetBitContext gb;
 
     int        prev_frame_num, frame_num;
