Where is the support for NV12 with 64x32 tiling is added ?

ssshukla26 ssshukla26 at gmail.com
Thu May 5 08:50:45 UTC 2016


Hi,

As you suggested, I made a C program to change NV12 tile to NV12 standard
format as follows, but am not getting desired output. Can you please suggest
what am missing ?

*convert_NV12TileToNV12.c*

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>

#define ROUND_UP_X(num,x) (((num)+(x-1))&~(x-1))

void copyTile(char **dst,char **src,int tile_size)
{
    memcpy(*dst,*src,tile_size);

    *dst = *dst + tile_size;
    *src = *src + tile_size;
}

void *NV12TileToNV12*(char* src,char* dst,int tile_size,int wTiles,int
hTiles)
{
    int i = 0;      //Loop Variable
    int Z = 0;      //For Z Flip Z Pattern
    char *X = NULL; //Source Even Line
    char *Y = NULL; //Source Odd Line

    //For a proper Z Flip Z pattern two consecutive rows are needed to be
process
    for(i = 0; i < (hTiles%2 == 0 ? hTiles : hTiles-1); i=i+2)
    {
        //Put X pointer at start of current row
        X = src;
        //Put Y pointer at start of next row
        Y = X + (tile_size * wTiles);

        for(Z = 0; Z < wTiles/2; Z++)
        {
            if(Z%2 == 0)
            {
                //For Z pattern
                copyTile(&dst,&X,tile_size*2);
                copyTile(&dst,&Y,tile_size*2);
            }
            else
            {
                //For Flip Z Pattern
                copyTile(&dst,&Y,tile_size*2);
                copyTile(&dst,&X,tile_size*2);
            }
        }

        //Move source pointer by two rows
        src = src + (2 * tile_size * wTiles);
    }

    //For linear pattern in last remaining row
    if(hTiles%2 != 0)
        copyTile(&dst,&src,(tile_size * wTiles));
}

int main(int argc, char* argv[])
{
    if(5 == argc)
    {
        if(strcmp(argv[1],argv[4]) != 0)
        {
            int infile = -1;
            if(-1 != (infile = open(argv[1],O_RDONLY)))
            {
                int outfile = -1;
                if(-1 != (outfile = open(argv[4],O_WRONLY | O_CREAT,0775)))
                {
                    int width = atoi(argv[2]);
                    int height = atoi(argv[3]);

                    int tile_size = 64*32;                          //Tile
size
                    int wTiles = ROUND_UP_X(width,128)/64;         
//Minimum no of columns required
                    int hTiles = ROUND_UP_X(height,32)/32;         
//Minimun no of rows required for Y Plane
                    int hTiles_UV = ROUND_UP_X(height/2,32)/32;    
//Minimum no of rows required for UV Plane

                    int frame_size = (tile_size * wTiles * hTiles) +
(tile_size * wTiles * hTiles_UV);
                    char *src_buf = (char *) calloc(1,frame_size);
                    char *dst_buf = (char *) calloc(1,frame_size);

                    printf("tile_size =
%d\nwTiles=%d\nhTiles=%d\nhTiles_UV=%d\nframe_size=%d\n",
                            tile_size,wTiles,hTiles,hTiles_UV,frame_size);

                    int cnt = 1;
                    while(read(infile,src_buf,frame_size))
                    {
                        //Convert Y Plane from NV12 tile to NV12 format
                       
*NV12TileToNV12*(src_buf,dst_buf,tile_size,wTiles,hTiles);
                        
                        //Convert UV Plane from NV12 tile to NV12 format
                        *NV12TileToNV12*(src_buf+(tile_size * wTiles *
hTiles),
                                dst_buf+(tile_size * wTiles * hTiles),
                                (tile_size/2),(wTiles*2),hTiles_UV);

                        if(frame_size != write(outfile,dst_buf,frame_size))
                        {
                            perror("Error writing output file :");
                            break;
                        }

                        printf("No of frames converted : %d\r",cnt++);
                        fflush(stdout);

                        memset(src_buf,'\0',sizeof(char) * frame_size);
                        memset(dst_buf,'\0',sizeof(char) * frame_size);
                    }

                    printf("\rNo of frames converted : %d\n",cnt);
                    fflush(stdout);

                    close(outfile);
                }
                else
                {
                    perror("Unable to open output file :");
                }

                close(infile);
            }
            else
            {
                perror("Unable to open input file :");
            }
        }
        else
        {
            printf("Input file name and output file name can't be same\n");
        }

    }
    else
    {
        printf("Usage: ./convert input_file width height output_file\n");
    }

    return 0;
}



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Where-is-the-support-for-NV12-with-64x32-tiling-is-added-tp4677225p4677338.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list