[cvs] / xvidcore / src / image / image.c Repository:
ViewVC logotype

Diff of /xvidcore/src/image/image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20.2.6, Wed Oct 9 15:56:16 2002 UTC revision 1.20.2.11, Sat Dec 14 06:07:03 2002 UTC
# Line 54  Line 54 
54  #include <math.h>  #include <math.h>
55    
56  #include "../portab.h"  #include "../portab.h"
57    #include "../global.h"                  // XVID_CSP_XXX's
58  #include "../xvid.h"                    // XVID_CSP_XXX's  #include "../xvid.h"                    // XVID_CSP_XXX's
59  #include "image.h"  #include "image.h"
60  #include "colorspace.h"  #include "colorspace.h"
61  #include "interpolate8x8.h"  #include "interpolate8x8.h"
62    #include "reduced.h"
63  #include "../divx4.h"  #include "../divx4.h"
64  #include "../utils/mem_align.h"  #include "../utils/mem_align.h"
65    
66    #include "font.h"               // XXX: remove later
67    
68  #define SAFETY  64  #define SAFETY  64
69  #define EDGE_SIZE2  (EDGE_SIZE/2)  #define EDGE_SIZE2  (EDGE_SIZE/2)
70    
# Line 320  Line 324 
324                                  h_ptr += 8;                                  h_ptr += 8;
325                          }                          }
326    
327                          hv_ptr += EDGE_SIZE2;                          hv_ptr += EDGE_SIZE;
328                          h_ptr += EDGE_SIZE2;                          h_ptr += EDGE_SIZE;
329    
330                          hv_ptr += stride_add;                          hv_ptr += stride_add;
331                          h_ptr += stride_add;                          h_ptr += stride_add;
# Line 472  Line 476 
476  }  }
477    
478    
479    /*
480    chroma optimize filter, invented by mf
481    a chroma pixel is average from the surrounding pixels, when the
482    correpsonding luma pixels are pure black or white.
483    */
484    
485    void
486    image_chroma_optimize(IMAGE * img, int width, int height, int edged_width)
487    {
488            int x,y;
489            int pixels = 0;
490    
491            for (y = 1; y < height/2 - 1; y++)
492            for (x = 1; x < width/2 - 1; x++)
493            {
494    #define IS_PURE(a)  ((a)<=16||(a)>=235)
495    #define IMG_Y(Y,X)      img->y[(Y)*edged_width + (X)]
496    #define IMG_U(Y,X)      img->u[(Y)*edged_width/2 + (X)]
497    #define IMG_V(Y,X)      img->v[(Y)*edged_width/2 + (X)]
498    
499                    if (IS_PURE(IMG_Y(y*2  ,x*2  )) &&
500                            IS_PURE(IMG_Y(y*2  ,x*2+1)) &&
501                            IS_PURE(IMG_Y(y*2+1,x*2  )) &&
502                            IS_PURE(IMG_Y(y*2+1,x*2+1)))
503                    {
504                            IMG_U(y,x) = (IMG_U(y,x-1) + IMG_U(y-1, x) + IMG_U(y, x+1) + IMG_U(y+1, x)) / 4;
505                            IMG_V(y,x) = (IMG_V(y,x-1) + IMG_V(y-1, x) + IMG_V(y, x+1) + IMG_V(y+1, x)) / 4;
506                            pixels++;
507                    }
508    
509    #undef IS_PURE
510    #undef IMG_Y
511    #undef IMG_U
512    #undef IMG_V
513            }
514    
515            DPRINTF(DPRINTF_DEBUG,"chroma_optimized_pixels = %i/%i", pixels, width*height/4);
516    }
517    
518    
519    
520    
521    
522    /*
523      perform safe packed colorspace conversion, by splitting
524      the image up into an optimized area (pixel width divisible by 16),
525      and two unoptimized/plain-c areas (pixel width divisible by 2)
526    */
527    
528    static void
529    safe_packed_conv(uint8_t * x_ptr, int x_stride,
530                                     uint8_t * y_ptr, uint8_t * u_ptr, uint8_t * v_ptr,
531                                     int y_stride, int uv_stride,
532                                     int width, int height, int vflip,
533                                     packedFunc * func_opt, packedFunc func_c, int size)
534    {
535            int width_opt, width_c;
536    
537            if (func_opt != func_c && x_stride < size*((width+15)/16)*16)
538            {
539                    width_opt = width & (~15);
540                    width_c = width - width_opt;
541            }
542            else
543            {
544                    width_opt = width;
545                    width_c = 0;
546            }
547    
548            func_opt(x_ptr, x_stride,
549                            y_ptr, u_ptr, v_ptr, y_stride, uv_stride,
550                            width_opt, height, vflip);
551    
552            if (width_c)
553            {
554                    func_c(x_ptr + size*width_opt, x_stride,
555                            y_ptr + width_opt, u_ptr + width_opt/2, v_ptr + width_opt/2,
556                            y_stride, uv_stride, width_c, height, vflip);
557            }
558    }
559    
560    
561    
562  int  int
563  image_input(IMAGE * image,  image_input(IMAGE * image,
564                          uint32_t width,                          uint32_t width,
565                          int height,                          int height,
566                          uint32_t edged_width,                          uint32_t edged_width,
567                          uint8_t * src,                          uint8_t * src,
568                          int csp)                          int src_stride,
569                            int csp,
570                            int interlacing)
571  {  {
572            const int edged_width2 = edged_width/2;
573            const int width2 = width/2;
574            const int height2 = height/2;
575            //const int height_signed = (csp & XVID_CSP_VFLIP) ? -height : height;
576    
577    
578  /*      if (csp & XVID_CSP_VFLIP)          //      int src_stride = width;
579    
580            // --- xvid 2.1 compatiblity patch ---
581            // --- remove when xvid_dec_frame->stride equals real stride
582            /*
583            if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB555 ||
584                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB565 ||
585                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_YUY2 ||
586                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_YVYU ||
587                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_UYVY)
588            {
589                    src_stride *= 2;
590            }
591            else if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB24)
592            {
593                    src_stride *= 3;
594            }
595            else if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB32 ||
596                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_ABGR ||
597                    (csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGBA)
598          {          {
599                  height = -height;                  src_stride *= 4;
600          }          }
601  */  */
602            // ^--- xvid 2.1 compatiblity fix ---^
603    
604          switch (csp & ~XVID_CSP_VFLIP) {          switch (csp & ~XVID_CSP_VFLIP) {
605          case XVID_CSP_RGB555:          case XVID_CSP_RGB555:
606                  rgb555_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
607                                             edged_width);                          src, src_stride, image->y, image->u, image->v,
608                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
609                            interlacing?rgb555i_to_yv12  :rgb555_to_yv12,
610                            interlacing?rgb555i_to_yv12_c:rgb555_to_yv12_c, 2);
611                    break;
612    
613          case XVID_CSP_RGB565:          case XVID_CSP_RGB565:
614                  rgb565_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
615                                             edged_width);                          src, src_stride, image->y, image->u, image->v,
616                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
617                            interlacing?rgb565i_to_yv12  :rgb565_to_yv12,
618                            interlacing?rgb565i_to_yv12_c:rgb565_to_yv12_c, 2);
619                    break;
620    
621    
622          case XVID_CSP_RGB24:          case XVID_CSP_RGB24:
623                  rgb24_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
624                                            edged_width);                          src, src_stride, image->y, image->u, image->v,
625                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
626                            interlacing?bgri_to_yv12  :bgr_to_yv12,
627                            interlacing?bgri_to_yv12_c:bgr_to_yv12_c, 3);
628                    break;
629    
630          case XVID_CSP_RGB32:          case XVID_CSP_RGB32:
631                  rgb32_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
632                                            edged_width);                          src, src_stride, image->y, image->u, image->v,
633                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
634                            interlacing?bgrai_to_yv12  :bgra_to_yv12,
635                            interlacing?bgrai_to_yv12_c:bgra_to_yv12_c, 4);
636                    break;
637    
638          case XVID_CSP_I420:          case XVID_CSP_ABGR :
639                  yuv_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
640                                          edged_width);                          src, src_stride, image->y, image->u, image->v,
641                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
642                            interlacing?abgri_to_yv12  :abgr_to_yv12,
643                            interlacing?abgri_to_yv12_c:abgr_to_yv12_c, 4);
644                    break;
645    
646          case XVID_CSP_YV12:             /* u/v swapped */          case XVID_CSP_RGBA :
647                  yuv_to_yv12(image->y, image->v, image->u, src, width, height,                  safe_packed_conv(
648                                          edged_width);                          src, src_stride, image->y, image->u, image->v,
649                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
650                            interlacing?rgbai_to_yv12  :rgba_to_yv12,
651                            interlacing?rgbai_to_yv12_c:rgba_to_yv12_c, 4);
652                    break;
653    
654          case XVID_CSP_YUY2:          case XVID_CSP_YUY2:
655                  yuyv_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
656                                           edged_width);                          src, src_stride, image->y, image->u, image->v,
657                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
658                            interlacing?yuyvi_to_yv12  :yuyv_to_yv12,
659                            interlacing?yuyvi_to_yv12_c:yuyv_to_yv12_c, 2);
660                    break;
661    
662          case XVID_CSP_YVYU:             /* u/v swapped */          case XVID_CSP_YVYU:             /* u/v swapped */
663                  yuyv_to_yv12(image->y, image->v, image->u, src, width, height,                  safe_packed_conv(
664                                           edged_width);                          src, src_stride, image->y, image->v, image->y,
665                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
666                            interlacing?yuyvi_to_yv12  :yuyv_to_yv12,
667                            interlacing?yuyvi_to_yv12_c:yuyv_to_yv12_c, 2);
668                    break;
669    
670          case XVID_CSP_UYVY:          case XVID_CSP_UYVY:
671                  uyvy_to_yv12(image->y, image->u, image->v, src, width, height,                  safe_packed_conv(
672                                           edged_width);                          src, src_stride, image->y, image->u, image->v,
673                  return 0;                          edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
674                            interlacing?uyvyi_to_yv12  :uyvy_to_yv12,
675                            interlacing?uyvyi_to_yv12_c:uyvy_to_yv12_c, 2);
676                    break;
677    
678            case XVID_CSP_I420:
679                    yv12_to_yv12(image->y, image->u, image->v, edged_width, edged_width2,
680                            src, src + width*height, src + width*height + width2*height2,
681                            width, width2, width, height, (csp & XVID_CSP_VFLIP));
682                    break
683                            ;
684            case XVID_CSP_YV12:             /* u/v swapped */
685                    yv12_to_yv12(image->y, image->v, image->u, edged_width, edged_width2,
686                            src, src + width*height, src + width*height + width2*height2,
687                            width, width2, width, height, (csp & XVID_CSP_VFLIP));
688                    break;
689    
690          case XVID_CSP_USER:          case XVID_CSP_USER:
691                  user_to_yuv_c(image->y, image->u, image->v, edged_width,                  {
692                                            (DEC_PICTURE *) src, width, height);                          DEC_PICTURE * pic = (DEC_PICTURE*)src;
693                  return 0;                          yv12_to_yv12(image->y, image->u, image->v, edged_width, edged_width2,
694                                    pic->y, pic->u, pic->v, pic->stride_y, pic->stride_y,
695                                    width, height, (csp & XVID_CSP_VFLIP));
696                    }
697                    break;
698    
699          case XVID_CSP_NULL:          case XVID_CSP_NULL:
700                  break;                  break;
701    
702            default :
703                    return -1;
704          }          }
705    
706          return -1;  
707            /* pad out image when the width and/or height is not a multiple of 16 */
708    
709            if (width & 15)
710            {
711                    int i;
712                    int pad_width = 16 - (width&15);
713                    for (i = 0; i < height; i++)
714                    {
715                            memset(image->y + i*edged_width + width,
716                                     *(image->y + i*edged_width + width - 1), pad_width);
717                    }
718                    for (i = 0; i < height/2; i++)
719                    {
720                            memset(image->u + i*edged_width2 + width2,
721                                     *(image->u + i*edged_width2 + width2 - 1),pad_width/2);
722                            memset(image->v + i*edged_width2 + width2,
723                                     *(image->v + i*edged_width2 + width2 - 1),pad_width/2);
724                    }
725            }
726    
727            if (height & 15)
728            {
729                    int pad_height = 16 - (height&15);
730                    int length = ((width+15)/16)*16;
731                    int i;
732                    for (i = 0; i < pad_height; i++)
733                    {
734                            memcpy(image->y + (height+i)*edged_width,
735                                       image->y + (height-1)*edged_width,length);
736                    }
737    
738                    for (i = 0; i < pad_height/2; i++)
739                    {
740                            memcpy(image->u + (height2+i)*edged_width2,
741                                       image->u + (height2-1)*edged_width2,length/2);
742                            memcpy(image->v + (height2+i)*edged_width2,
743                                       image->v + (height2-1)*edged_width2,length/2);
744                    }
745            }
746    
747    /*
748            if (interlacing)
749                    image_printf(image, edged_width, height, 5,5, "[i]");
750            image_dump_yuvpgm(image, edged_width, ((width+15)/16)*16, ((height+15)/16)*16, "\\encode.pgm");
751    */
752            return 0;
753  }  }
754    
755    
# Line 556  Line 761 
761                           uint32_t edged_width,                           uint32_t edged_width,
762                           uint8_t * dst,                           uint8_t * dst,
763                           uint32_t dst_stride,                           uint32_t dst_stride,
764                           int csp)                           int csp,
765                             int interlacing)
766  {  {
767          if (csp & XVID_CSP_VFLIP) {          const int edged_width2 = edged_width/2;
768                  height = -height;          int width2 = width/2;
769          }          int height2 = height/2;
770    
771    /*
772            if (interlacing)
773                    image_printf(image, edged_width, height, 5,100, "[i]=%i,%i",width,height);
774            image_dump_yuvpgm(image, edged_width, width, height, "\\decode.pgm");
775    */
776    
777    
778          // --- xvid 2.1 compatiblity patch ---          // --- xvid 2.1 compatiblity patch ---
779          // --- remove when xvid_dec_frame->stride equals real stride          // --- remove when xvid_dec_frame->stride equals real stride
780            /*
781          if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB555 ||          if ((csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB555 ||
782                  (csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB565 ||                  (csp & ~XVID_CSP_VFLIP) == XVID_CSP_RGB565 ||
783                  (csp & ~XVID_CSP_VFLIP) == XVID_CSP_YUY2 ||                  (csp & ~XVID_CSP_VFLIP) == XVID_CSP_YUY2 ||
# Line 582  Line 796 
796          {          {
797                  dst_stride *= 4;                  dst_stride *= 4;
798          }          }
799            */
800          // ^--- xvid 2.1 compatiblity fix ---^          // ^--- xvid 2.1 compatiblity fix ---^
801    
802    
803          switch (csp & ~XVID_CSP_VFLIP) {          switch (csp & ~XVID_CSP_VFLIP) {
804          case XVID_CSP_RGB555:          case XVID_CSP_RGB555:
805                  yv12_to_rgb555(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
806                                             edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
807                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
808                            interlacing?yv12_to_rgb555i  :yv12_to_rgb555,
809                            interlacing?yv12_to_rgb555i_c:yv12_to_rgb555_c, 2);
810                  return 0;                  return 0;
811    
812          case XVID_CSP_RGB565:          case XVID_CSP_RGB565:
813                  yv12_to_rgb565(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
814                                             edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
815                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
816                            interlacing?yv12_to_rgb565i  :yv12_to_rgb565,
817                            interlacing?yv12_to_rgb565i_c:yv12_to_rgb565_c, 2);
818                  return 0;                  return 0;
819    
820          case XVID_CSP_RGB24:          case XVID_CSP_RGB24:
821                  yv12_to_rgb24(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
822                                            edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
823                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
824                            interlacing?yv12_to_bgri  :yv12_to_bgr,
825                            interlacing?yv12_to_bgri_c:yv12_to_bgr_c, 3);
826                  return 0;                  return 0;
827    
828          case XVID_CSP_RGB32:          case XVID_CSP_RGB32:
829                  yv12_to_rgb32(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
830                                            edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
831                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
832                            interlacing?yv12_to_bgrai  :yv12_to_bgra,
833                            interlacing?yv12_to_bgrai_c:yv12_to_bgra_c, 4);
834                  return 0;                  return 0;
835    
836          case XVID_CSP_ABGR:          case XVID_CSP_ABGR:
837                  yv12_to_abgr(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
838                                            edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
839                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
840                            interlacing?yv12_to_abgri  :yv12_to_abgr,
841                            interlacing?yv12_to_abgri_c:yv12_to_abgr_c, 4);
842                  return 0;                  return 0;
843    
844          case XVID_CSP_RGBA:          case XVID_CSP_RGBA:
845                  yv12_to_rgba(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
846                                            edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
847                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
848                            interlacing?yv12_to_rgbai  :yv12_to_rgba,
849                            interlacing?yv12_to_rgbai_c:yv12_to_rgba_c, 4);
850                  return 0;                  return 0;
851    
852          case XVID_CSP_I420:          case XVID_CSP_YUY2:
853                  yv12_to_yuv(dst, dst_stride, image->y, image->u, image->v, edged_width,                  safe_packed_conv(
854                                          edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
855                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
856                            interlacing?yv12_to_yuyvi  :yv12_to_yuyv,
857                            interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2);
858                  return 0;                  return 0;
859    
860          case XVID_CSP_YV12:             // u,v swapped          case XVID_CSP_YVYU:             // u,v swapped
861                  yv12_to_yuv(dst, dst_stride, image->y, image->v, image->u, edged_width,                  safe_packed_conv(
862                                          edged_width / 2, width, height);                          dst, dst_stride, image->y, image->v, image->u,
863                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
864                            interlacing?yv12_to_yuyvi  :yv12_to_yuyv,
865                            interlacing?yv12_to_yuyvi_c:yv12_to_yuyv_c, 2);
866                  return 0;                  return 0;
867    
868          case XVID_CSP_YUY2:          case XVID_CSP_UYVY:
869                  yv12_to_yuyv(dst, dst_stride, image->y, image->u, image->v,                  safe_packed_conv(
870                                           edged_width, edged_width / 2, width, height);                          dst, dst_stride, image->y, image->u, image->v,
871                            edged_width, edged_width2, width, height, (csp & XVID_CSP_VFLIP),
872                            interlacing?yv12_to_uyvyi  :yv12_to_uyvy,
873                            interlacing?yv12_to_uyvyi_c:yv12_to_uyvy_c, 2);
874                  return 0;                  return 0;
875    
876          case XVID_CSP_YVYU:             // u,v swapped          case XVID_CSP_I420:
877                  yv12_to_yuyv(dst, dst_stride, image->y, image->v, image->u,                  yv12_to_yv12(dst, dst + width*height, dst + width*height + width2*height2,
878                                           edged_width, edged_width / 2, width, height);                          width, width2,
879                            image->y, image->u, image->v, edged_width, edged_width2,
880                            width, height, (csp & XVID_CSP_VFLIP));
881                  return 0;                  return 0;
882    
883          case XVID_CSP_UYVY:          case XVID_CSP_YV12:             // u,v swapped
884                  yv12_to_uyvy(dst, dst_stride, image->y, image->u, image->v,                  yv12_to_yv12(dst, dst + width*height, dst + width*height + width2*height2,
885                                           edged_width, edged_width / 2, width, height);                          width, width2,
886                            image->y, image->v, image->u, edged_width, edged_width2,
887                            width, height, (csp & XVID_CSP_VFLIP));
888                  return 0;                  return 0;
889    
890          case XVID_CSP_USER:          case XVID_CSP_USER:
891                  ((DEC_PICTURE *) dst)->y = image->y;                  {
892                  ((DEC_PICTURE *) dst)->u = image->u;                          DEC_PICTURE * pic = (DEC_PICTURE*)dst;
893                  ((DEC_PICTURE *) dst)->v = image->v;                          pic->y = image->y;
894                  ((DEC_PICTURE *) dst)->stride_y = edged_width;                          pic->u = image->u;
895                  ((DEC_PICTURE *) dst)->stride_uv = edged_width / 2;                          pic->v = image->v;
896                            pic->stride_y = edged_width;
897                            pic->stride_uv = edged_width / 2;
898                    }
899                  return 0;                  return 0;
900    
901          case XVID_CSP_NULL:          case XVID_CSP_NULL:
# Line 849  Line 1098 
1098      sV += std2;      sV += std2;
1099    }    }
1100  }  }
1101    
1102    
1103    void
1104    image_clear(IMAGE * img, int width, int height, int edged_width,
1105                                            int y, int u, int v)
1106    {
1107            uint8_t * p;
1108            int i;
1109    
1110            p = img->y;
1111            for (i = 0; i < height; i++) {
1112                    memset(p, y, width);
1113                    p += edged_width;
1114            }
1115    
1116            p = img->u;
1117            for (i = 0; i < height/2; i++) {
1118                    memset(p, u, width/2);
1119                    p += edged_width/2;
1120            }
1121    
1122            p = img->v;
1123            for (i = 0; i < height/2; i++) {
1124                    memset(p, v, width/2);
1125                    p += edged_width/2;
1126            }
1127    }
1128    
1129    
1130    /* reduced resolution deblocking filter
1131            block = block size (16=rrv, 8=full resolution)
1132            flags = XVID_DEC_YDEBLOCK|XVID_DEC_UVDEBLOCK
1133    */
1134    void
1135    image_deblock_rrv(IMAGE * img, int edged_width,
1136                                    const MACROBLOCK * mbs, int mb_width, int mb_height, int mb_stride,
1137                                    int block, int flags)
1138    {
1139            const int edged_width2 = edged_width /2;
1140            const int nblocks = block / 8;  /* skals code uses 8pixel block uints */
1141            int i,j;
1142    
1143            /* luma: j,i in block units */
1144            if ((flags & XVID_DEC_DEBLOCKY))
1145            {
1146                    for (j = 1; j < mb_height*2; j++)               /* horizontal deblocking */
1147                    for (i = 0; i < mb_width*2; i++)
1148                    {
1149                            if (mbs[(j-1)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED ||
1150                                    mbs[(j+0)/2*mb_stride + (i/2)].mode != MODE_NOT_CODED)
1151                            {
1152                                    xvid_HFilter_31_C(img->y + (j*block - 1)*edged_width + i*block,
1153                                                                      img->y + (j*block + 0)*edged_width + i*block, nblocks);
1154                            }
1155                    }
1156    
1157                    for (j = 0; j < mb_height*2; j++)               /* vertical deblocking */
1158                    for (i = 1; i < mb_width*2; i++)
1159                    {
1160                            if (mbs[(j/2)*mb_stride + (i-1)/2].mode != MODE_NOT_CODED ||
1161                                    mbs[(j/2)*mb_stride + (i+0)/2].mode != MODE_NOT_CODED)
1162                            {
1163                                    vfilter_31(img->y + (j*block)*edged_width + i*block - 1,
1164                                                       img->y + (j*block)*edged_width + i*block + 0,
1165                                                       edged_width, nblocks);
1166                            }
1167                    }
1168            }
1169    
1170    
1171            /* chroma */
1172            if ((flags & XVID_DEC_DEBLOCKUV))
1173            {
1174                    for (j = 0; j < mb_height; j++)                 /* horizontal deblocking */
1175                    for (i = 1; i < mb_width; i++)
1176                    {
1177                            if (mbs[j*mb_stride + i - 1].mode != MODE_NOT_CODED ||
1178                                    mbs[j*mb_stride + i + 0].mode != MODE_NOT_CODED)
1179                            {
1180                                    vfilter_31(img->u + (j*block)*edged_width2 + i*block - 1,
1181                                                       img->u + (j*block)*edged_width2 + i*block + 0,
1182                                                       edged_width2, nblocks);
1183                                    vfilter_31(img->v + (j*block)*edged_width2 + i*block - 1,
1184                                                       img->v + (j*block)*edged_width2 + i*block + 0,
1185                                                       edged_width2, nblocks);
1186                            }
1187                    }
1188    
1189                    for (j = 1; j < mb_height; j++)         /* vertical deblocking */
1190                    for (i = 0; i < mb_width; i++)
1191                    {
1192                            if (mbs[(j-1)*mb_stride + i].mode != MODE_NOT_CODED ||
1193                                    mbs[(j+0)*mb_stride + i].mode != MODE_NOT_CODED)
1194                            {
1195                                    hfilter_31(img->u + (j*block - 1)*edged_width2 + i*block,
1196                                                       img->u + (j*block + 0)*edged_width2 + i*block, nblocks);
1197                                    hfilter_31(img->v + (j*block - 1)*edged_width2 + i*block,
1198                                                       img->v + (j*block + 0)*edged_width2 + i*block, nblocks);
1199                            }
1200                    }
1201            }
1202    
1203    }

Legend:
Removed from v.1.20.2.6  
changed lines
  Added in v.1.20.2.11

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4