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/aacdec_template.c b/libavcodec/aacdec_template.c
index c2d7d05..a4aff59 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -2897,6 +2897,70 @@ static int aac_decode_er_frame(AVCodecContext *avctx, void *data,
     return 0;
 }
 
+/**
+ * Make AAC audio config object.
+ * @see 1.6.2.1 "Syntax - AudioSpecificConfig"
+ */
+
+static void put_audio_specific_config(AVCodecContext *avctx,int sr_index,int channels)
+{
+    PutBitContext pb;
+
+    init_put_bits(&pb, avctx->extradata, avctx->extradata_size*8);
+    if(avctx->extradata_size == 2) {
+       put_bits(&pb, 5, 2); //object type: AAC-LC = 2, AAC-HE = SBR = 5
+       put_bits(&pb, 4, sr_index); //sample rate index
+       put_bits(&pb, 4, channels);
+      //GASpecificConfig
+       put_bits(&pb, 1, 0); //frame length - 1024 samples
+       put_bits(&pb, 1, 0); //does not depend on core coder
+       put_bits(&pb, 1, 0); //is not extension
+    }
+    else {
+       uint8_t temp;
+       const uint16_t ui16SyncExtensionType = 0x2B7;
+       int ui32Extn_sr_index;
+        
+       for(ui32Extn_sr_index = 0; ui32Extn_sr_index < 16; ui32Extn_sr_index++)
+          if(avctx->sample_rate>>1 == avpriv_mpeg4audio_sample_rates[ui32Extn_sr_index])
+             break;
+
+       if(ui32Extn_sr_index == 16) {
+            av_log(avctx, AV_LOG_ERROR, "Unsupported Extn sample rate %d\n", avctx->sample_rate);
+            return;
+        }
+
+        temp = (2 << 3) | ((ui32Extn_sr_index & 0x0E)>>1);
+        put_bits(&pb, 8, temp);                             //0th byte
+
+        if(avctx->extradata_size == 5)
+           temp = ((ui32Extn_sr_index & 0x01) << 7) | (channels << 3);
+        else
+           temp = ((ui32Extn_sr_index & 0x01) << 7) | (1 << 3);
+        put_bits(&pb, 8, temp);                             //1 st byte
+
+        temp = (ui16SyncExtensionType >> 3) & 0xFF;
+        put_bits(&pb, 8, temp);                             // 2nd byte
+
+        temp = ((ui16SyncExtensionType & 0x7) << 5) | 5 ; /* ext ot id */
+        put_bits(&pb, 8, temp);                             // 3rd byte
+
+        if(avctx->extradata_size == 5) {
+           temp = ((1 & 0x1) << 7) | (sr_index << 3);
+           put_bits(&pb, 8, temp);                        // 4th byte
+        }
+        else {
+           temp = ((1 & 0x1) << 7) | (sr_index << 3) | 5;  // 4th byte
+           put_bits(&pb, 8, temp);
+
+           put_bits(&pb, 8, 0x48);                        // 5th Byte
+
+           put_bits(&pb, 8, 0x80);                         // 6th Byte
+        }
+    }
+    flush_put_bits(&pb);
+}
+
 static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
                                 int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
 {
@@ -3046,6 +3110,26 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
         ac->oc[1].status = OC_LOCKED;
     }
 
+    if(!avctx->extradata_size) {
+        int sr_index;
+        avctx->extradata_size = 2;
+
+        if(ac->oc[1].m4ac.sbr == 1)
+           avctx->extradata_size = 5;
+        if(ac->oc[1].m4ac.ps == 1)
+           avctx->extradata_size = 7;
+        if(!(avctx->extradata = av_mallocz(avctx->extradata_size)))
+           return AVERROR(ENOMEM);
+        for(sr_index = 0; sr_index < 16; sr_index++)
+          if(avctx->sample_rate == avpriv_mpeg4audio_sample_rates[sr_index])
+             break;
+        if(sr_index == 16) {
+           av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n",avctx->sample_rate);
+           return 0;
+        }
+        put_audio_specific_config(avctx,sr_index,avctx->channels);
+    }
+
     if (multiplier) {
         int side_size;
         const uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
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;
