comparison h264.c @ 9831:febe1855b64a libavcodec

Add field prev_interlaced_frame to H264Context to be able to flag soft telecine progressive. Patch by Haruhiko Yamagata, h D yamagata A nifty D com
author cehoyos
date Tue, 09 Jun 2009 21:16:40 +0000
parents 3fbd5452cbd1
children db929fcaeb9a
comparison
equal deleted inserted replaced
9830:bd0879f752e6 9831:febe1855b64a
3151 if(h->delayed_pic[i]) 3151 if(h->delayed_pic[i])
3152 h->delayed_pic[i]->reference= 0; 3152 h->delayed_pic[i]->reference= 0;
3153 h->delayed_pic[i]= NULL; 3153 h->delayed_pic[i]= NULL;
3154 } 3154 }
3155 h->outputed_poc= INT_MIN; 3155 h->outputed_poc= INT_MIN;
3156 h->prev_interlaced_frame = 1;
3156 idr(h); 3157 idr(h);
3157 if(h->s.current_picture_ptr) 3158 if(h->s.current_picture_ptr)
3158 h->s.current_picture_ptr->reference= 0; 3159 h->s.current_picture_ptr->reference= 0;
3159 h->s.first_field= 0; 3160 h->s.first_field= 0;
3160 reset_sei(h); 3161 reset_sei(h);
3805 if(h != h0) 3806 if(h != h0)
3806 return -1; // we cant (re-)initialize context during parallel decoding 3807 return -1; // we cant (re-)initialize context during parallel decoding
3807 if (MPV_common_init(s) < 0) 3808 if (MPV_common_init(s) < 0)
3808 return -1; 3809 return -1;
3809 s->first_field = 0; 3810 s->first_field = 0;
3811 h->prev_interlaced_frame = 1;
3810 3812
3811 init_scan_tables(h); 3813 init_scan_tables(h);
3812 alloc_tables(h); 3814 alloc_tables(h);
3813 3815
3814 for(i = 1; i < s->avctx->thread_count; i++) { 3816 for(i = 1; i < s->avctx->thread_count; i++) {
7787 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) { 7789 if (cur->field_poc[0]==INT_MAX || cur->field_poc[1]==INT_MAX) {
7788 /* Wait for second field. */ 7790 /* Wait for second field. */
7789 *data_size = 0; 7791 *data_size = 0;
7790 7792
7791 } else { 7793 } else {
7794 cur->interlaced_frame = 0;
7792 cur->repeat_pict = 0; 7795 cur->repeat_pict = 0;
7793 7796
7794 /* Signal interlacing information externally. */ 7797 /* Signal interlacing information externally. */
7795 /* Prioritize picture timing SEI information over used decoding process if it exists. */ 7798 /* Prioritize picture timing SEI information over used decoding process if it exists. */
7796 if (h->sei_ct_type & 3)
7797 cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
7798 else
7799 cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
7800 7799
7801 if(h->sps.pic_struct_present_flag){ 7800 if(h->sps.pic_struct_present_flag){
7802 switch (h->sei_pic_struct) 7801 switch (h->sei_pic_struct)
7803 { 7802 {
7803 case SEI_PIC_STRUCT_FRAME:
7804 break;
7805 case SEI_PIC_STRUCT_TOP_FIELD:
7806 case SEI_PIC_STRUCT_BOTTOM_FIELD:
7807 cur->interlaced_frame = 1;
7808 break;
7809 case SEI_PIC_STRUCT_TOP_BOTTOM:
7810 case SEI_PIC_STRUCT_BOTTOM_TOP:
7811 if (FIELD_OR_MBAFF_PICTURE)
7812 cur->interlaced_frame = 1;
7813 else
7814 // try to flag soft telecine progressive
7815 cur->interlaced_frame = h->prev_interlaced_frame;
7816 break;
7804 case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: 7817 case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
7805 case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: 7818 case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
7806 // Signal the possibility of telecined film externally (pic_struct 5,6) 7819 // Signal the possibility of telecined film externally (pic_struct 5,6)
7807 // From these hints, let the applications decide if they apply deinterlacing. 7820 // From these hints, let the applications decide if they apply deinterlacing.
7808 cur->repeat_pict = 1; 7821 cur->repeat_pict = 1;
7809 break; 7822 break;
7810 case SEI_PIC_STRUCT_FRAME_DOUBLING: 7823 case SEI_PIC_STRUCT_FRAME_DOUBLING:
7811 // Force progressive here, as doubling interlaced frame is a bad idea. 7824 // Force progressive here, as doubling interlaced frame is a bad idea.
7812 cur->interlaced_frame = 0;
7813 cur->repeat_pict = 2; 7825 cur->repeat_pict = 2;
7814 break; 7826 break;
7815 case SEI_PIC_STRUCT_FRAME_TRIPLING: 7827 case SEI_PIC_STRUCT_FRAME_TRIPLING:
7816 cur->interlaced_frame = 0;
7817 cur->repeat_pict = 4; 7828 cur->repeat_pict = 4;
7818 break; 7829 break;
7819 } 7830 }
7831
7832 if ((h->sei_ct_type & 3) && h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
7833 cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
7820 }else{ 7834 }else{
7821 /* Derive interlacing flag from used decoding process. */ 7835 /* Derive interlacing flag from used decoding process. */
7822 cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE; 7836 cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
7823 } 7837 }
7838 h->prev_interlaced_frame = cur->interlaced_frame;
7824 7839
7825 if (cur->field_poc[0] != cur->field_poc[1]){ 7840 if (cur->field_poc[0] != cur->field_poc[1]){
7826 /* Derive top_field_first from field pocs. */ 7841 /* Derive top_field_first from field pocs. */
7827 cur->top_field_first = cur->field_poc[0] < cur->field_poc[1]; 7842 cur->top_field_first = cur->field_poc[0] < cur->field_poc[1];
7828 }else{ 7843 }else{