jpg decode using vpudec ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

jpg decode using vpudec ?

Jump to solution
4,242 Views
alokkumar
Contributor III

Dear all,

I searched the forum and found this question was asked earlier but no clear answer mentioned. Could someone from freescale tell how to decode jpeg using vpudec commandline or C code. I am it will be extremely useful for me and many more.

https://community.freescale.com/thread/304879

gst-launch filesrc location=./jeep.jpg ! vpudec ! imagefreeze ! mfw_isink axis

-top=540 axis-left=960 disp-width=960 disp-height=540

MFW_GST_ISINK_PLUGIN 3.0.5 build on Apr 17 2013 12:11:46.

Setting pipeline to PAUSED ...

[INFO]  Product Info: i.MX6Q/D/S

vpudec versions

        plugin: 3.0.5

        wrapper: 1.0.28(VPUWRAPPER_ARM_LINUX Build on Apr 17 2013 12:09:59)

        vpulib: 5.4.10

        firmware: 2.1.8.34588

Pipeline is PREROLLING ...

** (gst-launch-0.10:1255): CRITICAL **: gst_vpudec_chain: assertion `vpudec->context.handle' failed

When I tried same with jpgdec, CPU went upto 100% on one core. It does display image.

Labels (5)
1 Solution
2,410 Views
LeonardoSandova
Specialist I

Hi Alok,

This pipeline works on my side and it is not using imagefreeze, the only problem is that display lasts for some milliseconds :smileyhappy:

VSALPHA=1 gst-launch filesrc location=sample.jpeg ! jpegdec ! mfw_isink

Leo

View solution in original post

0 Kudos
10 Replies
2,410 Views
jack_mao
NXP Employee
NXP Employee

Hi Alok,

    There is some sample code I have done before for alsa sound , you could refer some part, by the way after use the gstreamer cmd , then use top command, after the picture displayed, the CPU load is very small, so I don't know how you test this, how and when?

GstBus *bus;
GstElement *pipeline;

GstElement *alsasrc,*appsink;
GstCaps *caps;
buffer_in = (char*) malloc( BUF_SIZE1); 
buffer_out = (char*) malloc( BUF_SIZE2);

loop = g_main_loop_new(NULL,FALSE);

gst_init(NULL,NULL);

pipeline = gst_pipeline_new("test");

alsasrc = gst_element_factory_make("alsasrc","alsasrc");
appsink = gst_element_factory_make("appsink","appsink");

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);

        gst_object_unref (bus);

//g_object_set(G_OBJECT(alsasrc),"device","hw:0,0,0",NULL);

caps = gst_caps_new_simple("audio/x-raw-int",
   "endianness",G_TYPE_INT,1234,
   "signed",G_TYPE_BOOLEAN,TRUE,
   "width",G_TYPE_INT,16,
   "depth",G_TYPE_INT,16,
   "rate",G_TYPE_INT,44100,
   "channels",G_TYPE_INT,2,
   NULL);
gst_app_sink_set_caps((GstAppSink *)appsink,caps);

g_object_set(G_OBJECT(appsink),"emit-signals",TRUE,NULL);
g_signal_connect(appsink,"new-buffer",G_CALLBACK(on_new_buffer_from_source),NULL);

gst_bin_add_many(GST_BIN(pipeline),alsasrc,appsink,NULL);

gst_element_link_many(alsasrc,appsink,NULL);
asrc_fd = asrc_init_config();
src = create_appsrc_pipeline();
gst_element_set_state(pipeline,GST_STATE_PLAYING);
g_main_loop_run(loop);

gst_element_set_state(pipeline,GST_STATE_NULL);

gst_object_unref(GST_OBJECT(pipeline));

2,410 Views
alokkumar
Contributor III

Thanks Junping for sharing the code.

I am not sure if this code is any different than what I put earlier.

Actually so far I have been unsuccessful in using jpegdec without imagefreeze for jpeg display even using gst-launch.

any inputs will be helpful.

0 Kudos
2,411 Views
LeonardoSandova
Specialist I

Hi Alok,

This pipeline works on my side and it is not using imagefreeze, the only problem is that display lasts for some milliseconds :smileyhappy:

VSALPHA=1 gst-launch filesrc location=sample.jpeg ! jpegdec ! mfw_isink

Leo

0 Kudos
2,410 Views
joanxie
NXP TechSupport
NXP TechSupport

it seems vpudec just can support mjpeg video, if one picture, need to use jpegdec.

0 Kudos
2,410 Views
alokkumar
Contributor III

With some reason I have been getting three issues with jpegdec

1. CPU utilization is very high, with 2 jpeg display it goes up to 100% on one core.

2. most of the jpeg files end up in source format error . Any suggestions how to play all jpeg files.

3. When I playing a picture I took from nokia lumia 920, it was split on the display. I was surprise to see that.

Any helping pointers are highly appreciated.

0 Kudos
2,409 Views
LeonardoSandova
Specialist I

Hi Alok.

Regarding 1, do you see the same behavior using gst-launch? It would be interesting to check which gst element is causing this high CPU usage, it may be the freeze element.

Regarding 2, It could be that those non-working jpegs have non-standard headers. Could you please post one of this to see the error/header?

Regarding 3, yes, This is a known issue. We are working on this.

Leo

0 Kudos
2,409 Views
alokkumar
Contributor III

Hi Leo,

1. I noticed that with gst-launch cpu load was almost 50% compare to C code(above). I was not sure why.

This was the original pipeline and after removing "imagefreeze" pipeline fails

gst-launch filesrc location=./jeep.jpg ! vpudec ! imagefreeze ! mfw_isink axis

-top=540 axis-left=960 disp-width=960 disp-height=540

I would be very interested to know if there is a way to do it without imagefreeze.

2. I am attaching jpeg file, which I could not play without aligning to 8 pixel boundary.

Thanks a lot

-Alok

0 Kudos
2,409 Views
jack_mao
NXP Employee
NXP Employee

1. CPU utilization is very high, with 2 jpeg display it goes up to 100% on one core.

the CPU usage should be high during a short period, because it's decode by software

2. most of the jpeg files end up in source format error . Any suggestions how to play all jpeg files.

didn't see that, could you check the your code according to the guide in this community

3. When I playing a picture I took from nokia lumia 920, it was split on the display. I was surprise to see that.

How large size is this picture?

0 Kudos
2,409 Views
alokkumar
Contributor III

Thanks Junping Mao.

1. cpu utilization remains high through out.

Please see the code and suggest if something is incorrect.

     GstBin *Bin;

      GstBus *bus;

      GMainLoop *Mainloop;

      gst_init (&argc,&argv);

      Mainloop = g_main_loop_new(NULL,FALSE);//NULL to use the current context and False to tell its not in running state

      GstElement *pipeline = gst_pipeline_new("PIPELINE");

      Bin = GST_BIN(pipeline);

      bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));

      source = gst_element_factory_make("filesrc","file-source");

      g_object_set(G_OBJECT(source),"location",argv[1],NULL);

      imagedecoder = gst_element_factory_make("jpegdec","decoder");

      imagefreeze = gst_element_factory_make("imagefreeze","imagefreeze");//"Vorbis audio decoder","vorbis");

      video_sink = gst_element_factory_make("mfw_isink","XV video sink ");

      int axis_top=0;

      int axis_left=0;

      int disp_width=1920;

      int disp_height=1080;

      g_object_set(G_OBJECT(video_sink),"axis-top",axis_top,"axis-left",axis_left,"disp-width",disp_width,"disp-height",disp_height,NULL);

    

      gst_bin_add(Bin,source);

      gst_bin_add_many(Bin,imagedecoder,imagefreeze,video_sink,NULL);

      gst_element_link(source,imagedecoder);

      gst_element_link(imagedecoder,imagefreeze);

      gst_element_link(imagefreeze,video_sink);

      gst_bus_add_watch(bus,process_message,Mainloop); //Mainloop is passed as user data as in the process_message actions are taken on the loop

      g_object_unref(bus);

      g_print("In playing state\n");

      gst_element_set_state(pipeline,GST_STATE_PLAYING);//Pipeline is also a bin and bin is also an element at abstract level and hence gst_element_set_state call is used to set state of pipeline.

      g_main_loop_run(Mainloop);

      g_print("In playing state2\n");

      gst_element_set_state(pipeline,GST_STATE_NULL);

      g_object_unref(G_OBJECT(pipeline));

    }

2. This problem was solved after making sure files are 8*8 pixel format.

3. I thing there is some issue with playing files bigger than 1080P.

Thanks

Alok

0 Kudos
2,409 Views
jack_mao
NXP Employee
NXP Employee

No, the vpudec doesn't support jpeg decode, you should use open source jpeg plugin, also in community has article to introduce how to enable the jpeg decode

0 Kudos