diff --git a/ffmpeg.c b/ffmpeg.c
index f766830..24daee7 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3816,7 +3816,17 @@ static int process_input(int file_index)
 
     sub2video_heartbeat(ist, pkt.pts);
 
-    process_input_packet(ist, &pkt);
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+    AVFormatContext *os_tmp = output_files[0]->ctx;
+    if(nb_output_streams > 1 || (os_tmp && os_tmp->oformat && strcmp(os_tmp->oformat->name,"image2") || (ist && ist->st && ist->st->parser && ist->st->parser->idr_frame == 1))) 
+    {
+    
+       av_log(NULL,AV_LOG_FATAL,"Thumbnail is:%d idr frame \n",ist->frames_decoded);
+#endif 
+       process_input_packet(ist, &pkt);
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+    }
+#endif
 
 discard_packet:
     av_free_packet(&pkt);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4222db6..3ff7c6d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4586,7 +4586,15 @@ typedef struct AVCodecParserContext {
      * will be used.
      */
     int key_frame;
-
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+    /*!
+     * Set by parser to 1 for IDR frames and 0 for non-IDR frames.
+     * It is initialized to -1, so if the parser doesn't set this flag,
+     * and a key frames is detected, then it will be considered as an
+     * IDR frame.
+     */
+    int idr_frame;
+#endif
     /**
      * Time difference in stream time base units from the pts of this
      * packet to the point at which the output from the decoder has converged
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 19d1aa3..3a1e6b9 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -229,6 +229,9 @@ static inline int parse_nal_units(AVCodecParserContext *s,
     s->key_frame         = 0;
     s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
 
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+s->idr_frame = 0;
+#endif
     h->avctx = avctx;
     ff_h264_reset_sei(h);
     h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
@@ -291,6 +294,9 @@ static inline int parse_nal_units(AVCodecParserContext *s,
             ff_h264_decode_sei(h);
             break;
         case NAL_IDR_SLICE:
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+            s->idr_frame = 1;
+#endif //
             s->key_frame = 1;
 
             h->prev_frame_num        = 0;
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index f5bfa24..a5a1e3c 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -81,6 +81,9 @@ found:
         if (ret != 0)
             goto err_out;
     }
+#if 1 /*  Sailaja, Aug 13th, 2015, Thumbnails perfmormance optimization by decoding only IDR frame */
+    s->idr_frame            = -1;
+#endif
     s->key_frame            = -1;
     s->convergence_duration = 0;
     s->dts_sync_point       = INT_MIN;
