Regarding to my previous post:
I have tried some other combinations of "./configure" options, but I still
get some errors.
So here are some question:

1) Can this be related to permission issues in Linux?(Since the libraries
should be installed in usr/local, and I am always asked for root password to
access it, is there a way to disable this password asking?)

2)Is any "./configure" option making me problems with debugging?

3) Is there anything wrong with the code, when I try to debug?
(It works fine, and compiles, and is a single file that I compile under GCC,
code is attached)


On Sun, Dec 21, 2008 at 7:25 PM, AliReza Khoshgoftar
<[email protected]>wrote:

> Hi, Sorry for bringing this thread up again.
> I have combined the tips of Michael and Peeyush.
> I rebuilt the ffmpeg to be debuggable(it should have been overwriten on my
> older version)
> I also installed "ddd"
> I run my simple decode program, and put a breakpoint on function
> "avcodec_decode_video()", but when I  do "step" , and reach that function,
> instead of getting into ffmpeg source code, and seeing the called files and
> functions, I get the following message:
>
> *(gdb) step
>> Single stepping until exit from function avcodec_decode_video,
>> which has no line number information.
>> Cannot access memory at address 0x18e
>> (gdb)
>> *
>
>
>
> Dose anybody have an idea what does it mean?
> Have I had a mistake in building ffmpeg to be debuggable? Or I am using
> "ddd" incorrectly?
> The code runs correctly, and decodes the video frames, but I can't get
> inside the functions.
>
> Thanks,
> Alireza
>
>
> On Thu, Dec 18, 2008 at 10:46 PM, Peeyush Mishra <[email protected]
> > wrote:
>
>> Put break point to the specific FUNCTION name and then do STEP , STEP
>>
>>
>> Thanks
>> Peeyush
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of AliReza Khoshgoftar
>> Sent: Friday, December 19, 2008 12:18 AM
>> To: Libav* user questions and discussions
>> Subject: Re: [libav-user] Debugging / Finding Function Stack in FFMPEG
>>
>> Thanks again.
>> I'm Debugging the executable fime under ddd, and it's great.
>> So, here's just another thing.
>> I want it to track the program with some more details. i.e. when it
>> arrives
>> to the line on which "avcodec_decode_video()" is called. it goes to the
>> source code for this function(which is in utils.c), and then shows me
>> exactly which parts of the source code are used in decoding.
>> So, What should I do to make it trace the program with thus much details?
>> (Currently, it only passes over functions like "avcodec_decode_video()" or
>> "av_read_frame()", etc, and doesn't get into the source code)
>>
>> Thanks
>> Alireza
>>
>> On Thu, Dec 18, 2008 at 12:55 AM, Peeyush Mishra
>> <[email protected]>wrote:
>>
>> > Lets consider ur exe name is X and file name Y
>> >
>> > Do following :
>> >
>> >
>> > ddd X
>> > u will get console
>> > break 1 (on main ())
>> > run Y
>> > then step
>> > step
>> >
>> > thanks
>> > Peeyush
>> >
>> > -----Original Message-----
>> > From: [email protected]
>> > [mailto:[email protected]] On Behalf Of AliReza
>> Khoshgoftar
>> > Sent: Thursday, December 18, 2008 10:44 AM
>> > To: Libav* user questions and discussions
>> > Subject: Re: [libav-user] Debugging / Finding Function Stack in FFMPEG
>> >
>> > Thanks very much for the help.
>> > I re-compiled ffmpeg with the options Michael told.
>> > And as the easiest option, I am trying ddd now.
>> > I have the package now.
>> > So, just a quick question, how should I pass a video file as an argument
>> to
>> > my executable file, when I run it on ddd?
>> > Since I just open the executable file from the file menu, but it can't
>> be
>> > executed unless I pass it a video.
>> >
>> >
>> > 2008/12/17 Peeyush Mishra <[email protected]>
>> >
>> > >
>> > > Why don't u use DDD debugger, run the executable and do "step" . It
>> will
>> > > tell you the relevant function and file...
>> > >
>> > > Thanks
>> > > Peeyush
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > -----Original Message-----
>> > > From: [email protected]
>> > > [mailto:[email protected]] On Behalf Of AliReza
>> > Khoshgoftar
>> > > Sent: Thursday, December 18, 2008 6:15 AM
>> > > To: Libavcodec / Libavformat Mailing List
>> > > Subject: [libav-user] Debugging / Finding Function Stack in FFMPEG
>> > >
>> > > Hi There,
>> > >
>> > > I had another question which maybe rather categorized as a programming
>> > > question, but anyway it may be good to ask it here. Since it is about
>> > > FFMPEG
>> > > somehow.
>> > > I wanted to see if there is anyway to debug an FFMPEG code, and see
>> the
>> > > function stack in Linux.
>> > > What I exactly wanna do is here:
>> > > I've made a simple code to decode a video and extract a frame.
>> > > I've compiled it using GCC and have the executable file.
>> > > Now, I wanna know while I am running the executable file on a video
>> which
>> > > functions in FFMPEG's source code are called exactly.
>> > > For example, I wanna see when I call "av_codec_decode_video", the
>> > "decode"
>> > > function inside this function points to which function in FFMPEG's
>> source
>> > > code?
>> > > Is there anyway to find it out in Linux, and have a list of the
>> functions
>> > > called during the program execution and the c file in which these
>> > functions
>> > > are located.
>> > >
>> > > Thanks is in Advance,
>> > > Alireza.
>> > >
>> > > PS:If you don't know of a way to do it Linux, but you believe it can
>> be
>> > > done
>> > > easily in Windows (e.g. in MVC++), I still appreciate your guidance on
>> > how
>> > > to do that
>> > > _______________________________________________
>> > > libav-user mailing list
>> > > [email protected]
>> > > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> > >
>> > > --
>> > > This message has been scanned for viruses and
>> > > dangerous content by MailScanner, and is
>> > > believed to be clean.
>> > >
>> > >
>> > > No virus found in this incoming message.
>> > > Checked by AVG.
>> > > Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> > > 12:00
>> > > AM
>> > >
>> > >
>> > > No virus found in this outgoing message.
>> > > Checked by AVG.
>> > > Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> > > 12:00
>> > > AM
>> > >
>> > >
>> > > _______________________________________________
>> > > libav-user mailing list
>> > > [email protected]
>> > > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> > >
>> > _______________________________________________
>> > libav-user mailing list
>> > [email protected]
>> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> >
>> > --
>> > This message has been scanned for viruses and
>> > dangerous content by MailScanner, and is
>> > believed to be clean.
>> >
>> >
>> > No virus found in this incoming message.
>> > Checked by AVG.
>> > Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> > 12:00
>> > AM
>> >
>> >
>> > No virus found in this outgoing message.
>> > Checked by AVG.
>> > Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> > 12:00
>> > AM
>> >
>> >
>> > _______________________________________________
>> > libav-user mailing list
>> > [email protected]
>> > https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> >
>> _______________________________________________
>> libav-user mailing list
>> [email protected]
>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG.
>> Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> 12:00
>> AM
>>
>>
>> No virus found in this outgoing message.
>> Checked by AVG.
>> Version: 7.5.552 / Virus Database: 270.9.18 - Release Date: 12/14/2008
>> 12:00
>> AM
>>
>>
>> _______________________________________________
>> libav-user mailing list
>> [email protected]
>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>>
>
>
// concealment.c

// gcc -o concealment concealment.c -lavutil -lavformat -lavcodec -lz
//


// concealment videofile.mpg
//

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"

/*
#include <iostream>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::ios;


#include <fstream> // file stream         
using std::ofstream; // output file stream

#include <cstdlib>
using std::exit; // exit function prototype
*/

#include <stdio.h>


/*FUNCTION TO SAVE THE VIDEO*/
void SaveFrame(AVFrame *pFrame, int width, int height, int iFrame) {
  FILE *pFile;
  char szFilename[32];
  int  y;
  
  // Open file
  sprintf(szFilename, "frame%d.ppm", iFrame);
  pFile=fopen(szFilename, "wb");
  if(pFile==NULL)
    return;
  
  // Write header
  fprintf(pFile, "P6\n%d %d\n255\n", width, height);
  
  // Write pixel data
  for(y=0; y<height; y++)
    fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);
  
  // Close file
  fclose(pFile);
}

/***************************************************************************************
****************************************************************************************
**************************************************************************************/

int main(int argc, char *argv[]) {
/*DEFINITIONS*/
  AVFormatContext *pFormatCtx;
  int             i, videoStream, j, k;
  AVCodecContext  *pCodecCtx;
  AVCodec         *pCodec;
  AVFrame         *pFrame; 
  AVFrame         *pFrameRGB;
  AVPacket        packet;
  int             frameFinished;
  int             numBytes;
  uint8_t         *buffer;
  

  //New Definitions
  static int      bytesRemaining=0;
  static uint8_t  *rawData, *prevData;
  static int     fFirstTime=1;
  int             bytesDecoded;


/***************************************************************************************/
/*INITIAL CHECKS, INITIALIZATIONS, OPEN VIEDO, FIND STREAMS, ETC.*/
  if(argc < 2) {
    printf("Please provide a movie file\n");
    return -1;
  }
  // Register all formats and codecs
  av_register_all();
  
  // Open video file
  if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
    return -1; // Couldn't open file
  
  // Retrieve stream information
  if(av_find_stream_info(pFormatCtx)<0)
    return -1; // Couldn't find stream information
  
  // Dump information about file onto standard error
  dump_format(pFormatCtx, 0, argv[1], 0);
  
  // Find the first video stream
  videoStream=-1;
  for(i=0; i<pFormatCtx->nb_streams; i++)
    if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO) {
      videoStream=i;
      break;
    }
  if(videoStream==-1)
    return -1; // Didn't find a video stream
  
  // Get a pointer to the codec context for the video stream
  pCodecCtx=pFormatCtx->streams[videoStream]->codec;
  
  //Enable FFMPEG's Error Concealment
  pCodecCtx->error_concealment = 1;

  // Find the decoder for the video stream
  pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
  


  if(pCodec==NULL) {
    fprintf(stderr, "Unsupported codec!\n");
  return -1; // Codec not found
  }
  // Open codec
  if(avcodec_open(pCodecCtx, pCodec)<0)
    return -1; // Could not open codec

/***************************************************************************************/
/*ALLOCATIONS*/
  // Allocate video frame
  pFrame=avcodec_alloc_frame();
  
  // Allocate an AVFrame structure
  pFrameRGB=avcodec_alloc_frame();
  if(pFrameRGB==NULL)
    return -1;
  
  // Determine required buffer size and allocate buffer
  numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,
			      pCodecCtx->height);
  buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));
  
  // Assign appropriate parts of buffer to image planes in pFrameRGB
  // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
  // of AVPicture
  avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
		 pCodecCtx->width, pCodecCtx->height);
  
/***************************************************************************************/
/*DECODING IS DONE HERE*/
  // Read frames and save first five frames to disk
  i=0;
  j=-1;
 while(av_read_frame(pFormatCtx, &packet)>=0) {
    j++;
    //See All Read Indices
    //printf("packet stream index is %d\n", packet.stream_index);
    // Is this a packet from the video stream?
    if(packet.stream_index==videoStream) {
         //Check the stream # Manually
         //printf("packet stream index is %d\n", packet.stream_index);
         /*
         //Check Packet Size Manually
         printf("packet size is %d\n", packet.size);
         printf("using size of Operator %d\n", sizeof(packet.data));
         printf("packet.data[0] is: %d\n", packet.data[0]);
         printf("packet.data[1] is: %d\n", packet.data[1]);
         printf("packet.data[2] is: %d\n", packet.data[2]);
         printf("packet.data[3] is: %d\n", packet.data[3]);
         printf("packet.data[4] is: %d\n", packet.data[4]);
         printf("packet.data[5] is: %d\n", packet.data[5]);
         printf("packet.data[6] is: %d\n", packet.data[6]);
         */
         //Check other Fiels
         //printf("Packet TimeStamp: %f\n", packet.pts);
         //if(fmod(j,5) == 0){
         //if(j!=0 || j!= 1){
         //     memset(packet.data, 0x0, packet.size);
         //  }
          /*
          FILE *inof
          inof = fopen("info.txt",w);
          fwrite(packet.data,packet.size,)
          */
      // Decode video frame
      avcodec_decode_video(pCodecCtx, pFrame, &frameFinished, 
			   packet.data, packet.size);
      
      // Did we get a video frame?
      if(frameFinished) {
	// Convert the image from its native format to RGB
	img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24, 
                    (AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx->width, 
                    pCodecCtx->height);
	
	// Save the frame to disk
	  SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height, 
		    i);
          i++;
      }
    }
}

  // Free the RGB image
  av_free(buffer);
  av_free(pFrameRGB);
  
  // Free the YUV frame
  av_free(pFrame);
  
  // Close the codec
  avcodec_close(pCodecCtx);
  
  // Close the video file
  av_close_input_file(pFormatCtx);
  
  printf("No of Packets = %d\n", j);
  printf("No of Frames = %d\n", i);
  printf("Video Stream = %d\n", videoStream);

 
  return 0;
}
/*
        if(fFirstTime)
    {
        fFirstTime=-1;
        packet.data=NULL;
    }
    // Decode packets until we have decoded a complete frame
    while(av_read_packet(pFormatCtx, &packet)>=0)
    { 
        if(packet.stream_index == videoStream)
        {
            // Read new packet
            
            if(fmod(j,5) == 0){
            //if(j!=0 || j!= 1){
                for( k=0 ; k < packet.size ; k++)
                   *(packet.data+k) = 0;
            } 
        rawData=packet.data;
        bytesRemaining=packet.size;
        j++;        
        prevData=packet.data;
        // Work on the current packet until we have decoded all of it
        while(bytesRemaining > 0)
        {
            // Decode the next chunk of data
            bytesDecoded=avcodec_decode_video(pCodecCtx, pFrame,
                &frameFinished, rawData, bytesRemaining);
             
            // Was there an error?
            if(bytesDecoded < 0)
            {
                fprintf(stderr, "Error while decoding frame\n");
                return -1;
            }

            bytesRemaining-=bytesDecoded;
            rawData+=bytesDecoded;

            // Did we finish the current frame? Then we can return

       if(frameFinished) {
	// Convert the image from its native format to RGB
	img_convert((AVPicture *)pFrameRGB, PIX_FMT_RGB24, 
                    (AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx->width, 
                    pCodecCtx->height);
	
	// Save the frame to disk
	//if(++i<=4)
	  SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,i);
        i++;
        }

        }
        }
        // Read the next packet, skipping all packets that aren't for this
        // stream

    }

loop_exit:

    // Decode the rest of the last frame
    bytesDecoded=avcodec_decode_video(pCodecCtx, pFrame, &frameFinished, 
        rawData, bytesRemaining);

    // Free last packet
    if(packet.data!=NULL)
        av_free_packet(&packet);

    return frameFinished!=0;

FILE *myInfoText;
myInfoText = fopen("myInfoText","wb");
 if(myInfoText==NULL)
    return;
fprintf(myInfoText,"i = %d\n",i);
fprintf(myInfoText,"j = %d",j);
fclose(myInfoText);

 // Free the RGB image
  av_free(buffer);
  av_free(pFrameRGB);
  
  // Free the YUV frame
  av_free(pFrame);

  
  // Close the codec
  avcodec_close(pCodecCtx);
  
  // Close the video file
  av_close_input_file(pFormatCtx);
*/   


_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to