CN104916298B - Decoding method, coding and decoding device, electronic equipment and talking picture generation method - Google Patents
Decoding method, coding and decoding device, electronic equipment and talking picture generation method Download PDFInfo
- Publication number
- CN104916298B CN104916298B CN201510283432.2A CN201510283432A CN104916298B CN 104916298 B CN104916298 B CN 104916298B CN 201510283432 A CN201510283432 A CN 201510283432A CN 104916298 B CN104916298 B CN 104916298B
- Authority
- CN
- China
- Prior art keywords
- audio
- identifier
- file
- audio data
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Television Signal Processing For Recording (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention discloses a kind of coding method, the described method includes:Obtain the first view data and the first voice data;First voice data is inserted into the file header of picture file according to preset strategy, and described first image data are synthesized into a file with first voice data.The present invention further simultaneously discloses a kind of coding/decoding method, code device, decoding apparatus, electronic equipment and sound photograph generation method.Technical solution using the present invention, it can realize that the coding of picture, audio in same file preserves, and decoding can be synchronized to sound photo and is played, also solve the problems, such as that sound photo is be easy to causeing voice data loss after the preservation of graph and image processing software editing in the prior art, improves user experience at the same time.
Description
Technical Field
The present invention relates to image processing technologies, and in particular, to an encoding and decoding method, an encoding and decoding device, an electronic device, and an audio picture generation method.
Background
Typically, people record life clips in the form of photos or videos. The sound photo is more and more popular because it can reproduce the real scene of the photo when it is taken for the person and other viewers of the photo.
At present, the sound photo technology is mainly divided into two types, one type is to store photos and audios in two files separately, but the method is inconvenient to spread and browse simultaneously; the other method is that the photos and the audios are stored in a file, and data in an audio format is directly inserted into the tail of the file in the picture format.
Disclosure of Invention
In view of the above, the present invention provides a coding and decoding method, a coding and decoding device, an electronic device, and an audio picture generating method, which can implement coding storage and synchronous decoding and playing of pictures and audio in the same file, and solve the problem in the prior art that audio data is easily lost after audio pictures are edited and stored by graphics image processing software.
In order to achieve the purpose, the technical scheme of the invention is realized as follows:
the invention provides an encoding method, which comprises the following steps:
acquiring first image data and first audio data;
and inserting the first audio data into a file header of a picture file according to a preset strategy, and synthesizing the first image data and the first audio data into a file.
Preferably, the preset policy includes:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
Preferably, before the acquiring the first image data and the first audio data, the method further includes:
and acquiring the picture coding format and the audio coding format selected by the user.
Preferably, the acquiring the first image data and the first audio data includes:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
The invention also provides a decoding method, which comprises the following steps:
detecting the format type of a file to be opened;
searching whether a first identifier exists in a file header of the file to be opened according to the format type;
when a first identifier exists, acquiring first audio data based on the first identifier;
and synchronously decoding the first audio data and the acquired first image data.
Preferably, the obtaining of the first audio data based on the first identifier includes:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
Preferably, the synchronously decoding the first audio data and the acquired first image data includes:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
Preferably, the controlling, by the main thread, the playing of the decoded audio data and the decoded image data includes:
and playing the decoded audio data and image data through a user interface.
The invention also provides a coding device, which comprises a first acquisition unit and a synthesis unit; wherein,
the first acquisition unit is used for acquiring a picture coding format and an audio coding format selected by a user;
the synthesis unit is used for inserting the first audio data into a file header of a picture file according to a preset strategy and synthesizing the first image data and the first audio data into one file.
Preferably, the preset policy includes:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
Preferably, before the acquiring the first image data and the first audio data, the method further includes:
and acquiring the picture coding format and the audio coding format selected by the user.
Preferably, the encoding apparatus further includes:
and the second acquisition unit is used for acquiring the picture coding format and the audio coding format selected by the user.
Preferably, the first obtaining unit is further configured to:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
The invention also provides a decoding device, which comprises a detection unit, a search unit, a third acquisition unit and a decoding unit; wherein,
the detection unit is used for detecting the format type of the file to be opened;
the searching unit is used for searching whether a first identifier exists in the file header of the file to be opened according to the format type;
the third acquisition unit is used for acquiring first audio data based on the first identifier when the first identifier exists;
the decoding unit is used for synchronously decoding the first audio data and the acquired first image data.
Preferably, the third obtaining unit is further configured to:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
Preferably, the decoding unit is further configured to:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
Preferably, the decoding unit is further configured to:
and playing the decoded audio data and image data through a user interface.
The present invention also provides an electronic device comprising at least a decoding apparatus as described above and/or a decoding apparatus as described above.
The invention also provides a method for generating the sound picture, which comprises the following steps:
acquiring at least one picture file and an audio file;
and inserting the audio data of the audio file into the file header of the picture file, and synthesizing the image data of the picture file and the audio data of the audio file into a file.
The coding and decoding method, the coding and decoding device, the electronic equipment and the audio photo generation method provided by the invention are used for acquiring first image data and first audio data; and inserting the first audio data into a file header of a picture file according to a preset strategy, and synthesizing the first image data and the first audio data into a file to obtain audio data. Therefore, the method can realize the coding and the storage of the picture and the audio in the same file, can synchronously decode and play the sound photo, and simultaneously solves the problem that the sound photo is easy to cause audio data loss after being edited and stored by the graphic image processing software in the prior art, thereby improving the user experience. Specifically, by adopting the technical scheme of the invention, the transmission and sharing of the sound photos are more convenient; even if the graphic image processing software is adopted for editing, the audio information can be stored and can not be lost, and the method is more reliable; the user experience is better as both pictures and sounds can be presented simultaneously.
Drawings
Fig. 1 is a first schematic flow chart illustrating an implementation of an encoding method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a flow chart of an implementation of the encoding method according to the embodiment of the present invention;
fig. 3 is a schematic flow chart of an encoding process of a voiced photograph according to an embodiment of the present invention;
fig. 4 is a schematic flow chart illustrating an implementation of a method for generating an audio picture according to an embodiment of the present invention;
fig. 5 is a schematic flow chart illustrating an implementation of a decoding method according to an embodiment of the present invention;
fig. 6 is a schematic processing flow diagram of a process of decoding a voiced picture according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an encoding apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention.
Detailed Description
So that the manner in which the features and aspects of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings.
Fig. 1 is a schematic view of a first implementation flow of an encoding method provided in an embodiment of the present invention, where the encoding method in the embodiment is applicable to an electronic device, as shown in fig. 1, the encoding method mainly includes the following steps:
step 101: first image data and first audio data are acquired.
Here, the first image data may refer to encoded image data; the first audio data may refer to encoded audio data.
In this embodiment, what picture coding format is specifically adopted to code the acquired image data may be determined according to default settings of the electronic device when the electronic device leaves a factory; similarly, what audio coding format is specifically adopted to code the collected audio data may be determined according to default settings of the electronic device when the electronic device leaves the factory.
Of course, a selection interface can be provided for the user, so that the user can select the picture coding format and the audio coding format according to the preference of the user.
Preferably, the acquiring the first image data and the first audio data may include:
coding the acquired picture data according to the picture coding format determined by the electronic equipment to generate first image data;
and coding the acquired audio data according to the audio coding format determined by the electronic equipment to generate first audio data.
When the setting operation of the picture coding format and the audio coding format by the user is not received, the picture coding format and the audio coding format determined by the electronic equipment are both default formats of the system;
when the setting operation of the picture coding format and the audio coding format by the user is received, the picture coding format and the audio coding format determined by the electronic equipment are both the image coding format and the audio coding format selected by the user.
In this embodiment, the electronic device is at least configured with:
image acquisition devices, such as cameras, for acquiring images;
and a sound collection device, such as a microphone, for capturing audio.
In this embodiment, the image data may be obtained by a camera of the electronic device; the audio data may be obtained by a microphone of the electronic device.
Preferably, the audio data may be acquired after the image data is acquired, or the audio data may be acquired simultaneously with the image data.
That is, the user can determine the photo he wants to take through the image preview interface, and then start recording after clicking the shooting button; or recording while clicking the shooting button.
Step 102: and inserting the first audio data into a file header of a picture file according to a preset strategy, and synthesizing the first image data and the first audio data into a file.
Preferably, the preset policy may include:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
That is, even if there is no audio identifier in the image file format standard, audio data can be inserted.
In the foregoing scheme, optionally, before the acquiring the first image data and the first audio data, the method may further include:
and acquiring the picture coding format and the audio coding format selected by the user.
Specifically, a user interface (UI interface for short) of the electronic device may be provided with a picture coding format selection dialog box in which a picture coding format supported by the electronic device is presented, and an audio coding format dialog box in which an audio coding format supported by the electronic device is presented, so that the user can select the picture coding format and the audio coding format according to his preference or habit.
Specifically, when the electronic device has a touch screen (i.e., supports touch input), the user may select the picture encoding format and the audio encoding format by touching with a finger, a touch pen, or the like. When the electronic device does not support touch input, the picture coding format and the audio coding format can be selected through the related keys.
Specifically, after the picture coding format and the audio coding format selected by the user for the first time are recorded, the picture coding format and the audio coding format set by the user for the first time may also be set as the default picture coding format and the default audio coding format until the user actively modifies the picture coding format and the audio coding format again.
In the foregoing scheme, optionally, the acquiring the first image data and the first audio data may include:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
In the embodiment of the invention, first image data and first audio data are acquired; inserting the first audio data into a file header of a picture file according to a preset strategy, and synthesizing the first image data and the first audio data into a file; therefore, no matter whether the image file format standard has an audio identifier corresponding to the picture coding format, the audio data can be inserted; the audio data is placed at the file header of the picture file, so that no matter how the picture is edited, the audio data reading is not influenced, the coding and the storage of the picture and the audio in the same file are realized, and the problem that the audio data are easily lost after the audio picture is edited and stored by the graphic image processing software in the prior art is solved.
Fig. 2 is a schematic view of an implementation flow of an encoding method according to an embodiment of the present invention, where the encoding method in the embodiment is applicable to an electronic device, as shown in fig. 2, the encoding method mainly includes the following steps:
step 201: and acquiring the picture coding format and the audio coding format selected by the user.
Here, the picture coding formats that can be selected by the user may be various, such as: BMP, JPG, TIFF, GIF, PCX, TGA, EXIF, FPX, SVG, PSD, CDR, PCD, DXF, UFO, EPS, AI, RAW, etc.
Here, the audio encoding format that can be selected by the user may be various, such as: CD. WAVE, AIFF, AU, MPEG, MP3, MIDI, WMA, VQF, AMR, etc.
Specifically, the UI interface of the electronic device may be provided with a picture coding format selection dialog box in which a picture coding format supported by the electronic device is presented, and an audio coding format dialog box in which an audio coding format supported by the electronic device is presented, so that a user can select the picture coding format and the audio coding format according to his/her preference or habit.
Specifically, when the electronic device has a touch screen (i.e., supports touch input), the user may select the picture encoding format and the audio encoding format by touching with a finger, a touch pen, or the like. When the electronic device does not support touch input, the picture coding format and the audio coding format can be selected through the related keys.
Specifically, after the picture coding format and the audio coding format selected by the user for the first time are recorded, the picture coding format and the audio coding format set by the user for the first time may also be set as the default picture coding format and the default audio coding format until the user actively modifies the picture coding format and the audio coding format again.
Step 202: first image data and first audio data are acquired.
Specifically, the first image data may be encoded image data, and the first audio data may be encoded audio data.
Preferably, the acquiring the first image data and the first audio data may include:
coding the acquired image data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
In this embodiment, the electronic device is at least configured with:
image acquisition devices, such as cameras, for acquiring images;
and a sound collection device, such as a microphone, for capturing audio.
In this embodiment, the image data may be obtained by a camera of the electronic device; the audio data may be obtained by a microphone of the electronic device.
Preferably, the audio data may be acquired after the image data is acquired, or the audio data may be acquired simultaneously with the image data.
That is, the user can determine the photo he wants to take through the image preview interface, and then start recording after clicking the shooting button; or recording while clicking the shooting button.
Step 203: and judging whether the picture coding format has an audio identifier in the image file format standard, and generating a judgment result.
Here, the image file format standard is an image file format standard in the related art.
For example, the Image File Format Standard may be a "digital Camera Image File Format Standard".
It should be noted that the order of step 202 and step 203 may be interchanged.
Step 204: and inserting the first audio data into a file header of a picture file based on the judgment result, and synthesizing the first image data and the first audio data into one file.
Preferably, the inserting the first audio data into a file header of a picture file based on the determination result and synthesizing the first image data and the first audio data into one file may include:
when the judgment result shows that the audio identifier exists, the audio identifier corresponding to the picture coding format is placed in a file header of the picture file, and first audio data are inserted after the audio identifier;
and after the first audio data is inserted, putting first image data into the audio data.
Here, the audio identifier is an audio identifier corresponding to the picture coding format, which has been defined in the existing image file format standard.
Preferably, the inserting the first audio data into a file header of a picture file based on the determination result, and synthesizing the first image data and the first audio data into one file may further include:
when the judgment result shows that no audio identifier exists, a starting identifier is placed in a reserved field of a file header of the picture file, first audio data is inserted after the starting identifier, and a finishing identifier is placed after the first audio data is inserted;
the first image data is then embedded.
Here, the start identifier is a symbol for representing the start of insertion of the first audio data, and the end identifier is a symbol for representing the end of insertion of the first audio data.
It should be noted that the start identifier and the end identifier can be recognized by the decoding apparatus of the present invention.
For example, when the judgment result is that there is no audio identifier, a start identifier and an end identifier are predefined, and the decoding apparatus is notified of the predefined start identifier and end identifier so that the decoding apparatus can decode the synthesized file.
Specifically, the format type of the synthesized file is the picture coding format type selected by the user in step 201.
Here, the synthesized file may be stored in a memory of the electronic device, or the synthesized file may be transmitted to the server through the electronic device to be saved by the server.
In this embodiment, the electronic device may be a device such as a mobile phone and a tablet computer, which has a camera and a microphone and has a coding function.
For example, a user selects an encoding format through a plug-in a camera application, taking a JPEG still image as an example, an identifier of 0x9286 can be defined in a header portion of a file, data of any format and any length is supported, a recording prompt pops up after a picture is taken, after the user records the sound, the user automatically encodes according to the encoding format selected by the user, a sound picture is synthesized, and then the sound picture is stored in a memory.
Note that, the 0x9286 is "interchangeable image file format digital camera: exif (Exchangeable image file format for Digital Still Cameras: Exif) standard version 2.1, the 0x9286 supports data of any format and any length.
Of course, the definition of the start identifier is not limited to only this form listed above, and is not listed here.
In the embodiment of the invention, the picture coding format and the audio coding format selected by a user are obtained; acquiring first image data and first audio data; judging whether the picture coding format has an audio identifier in an image file format standard or not, and generating a judgment result; inserting the first audio data into a file header of a picture file based on the judgment result, and synthesizing the first image data and the first audio data into one file; therefore, the audio data is placed at the file header of the picture file, no matter how the picture is edited, the audio data reading is not influenced, the coding and the storage of the picture and the audio in the same file are realized, and the problem that the audio data are easily lost after the audio picture is edited and stored by the graphic image processing software in the prior art is solved.
Fig. 3 is a schematic flowchart of an encoding process of a voiced photograph according to an embodiment of the present invention, and as shown in fig. 3, the process mainly includes the following steps:
step 301, receiving a picture coding format and an audio coding format specified by a user;
here, the designation of the user may be received through the UI interface.
Step 302: coding the acquired audio data according to an audio coding format to generate first audio data;
step 303: judging whether the specified picture coding format has an audio identifier in the image file format standard, if so, executing step 304; if not, go to step 306;
step 304: an audio identifier in the standard is placed in the header information, and then step 305 is performed;
here, the standard refers to the image file format standard described in step 303.
Step 305: placing the first audio data after the audio identifier, and then performing step 309;
step 306: a start identifier is placed in the reserved field of the header and then step 307 is performed;
wherein the start identifier is recognizable by the decoding apparatus of the present invention.
Step 307: inserting the first audio data after the start identifier and then performing step 308;
step 308: after the first audio data is completely embedded, embedding an end identifier, and then executing step 309;
wherein the end identifier is recognizable by the decoding apparatus of the present invention.
Step 309: the first image data is placed, and then step 308 is executed;
here, the first image data is data obtained by encoding the acquired image data in accordance with a picture encoding format specified by a user.
When the first image data is generated in particular, this may be done during steps 302 to 308.
Step 310: the first audio data and the first image data are synthesized into one file.
Specifically, the synthesized file may be stored in a device having a storage function, such as a memory or a cloud server.
The execution subjects of the above steps 301 to 310 may be encoding devices, or may be electronic apparatuses having encoding devices.
Fig. 4 is a schematic flow chart illustrating an implementation of a method for generating an audio picture according to an embodiment of the present invention; the audio picture generation in the present embodiment can be applied to an electronic device, and as shown in fig. 4, the audio picture generation mainly includes the following steps:
step 401: at least one picture file and one audio file are obtained.
Here, the picture file may be from a first device, and the audio file may be from a second device;
the first device and the second device may be the same device or different devices; the first device and the second device may be third party devices different from electronic devices.
Step 402: and inserting the audio data of the audio file into the file header of the picture file, and synthesizing the image data of the picture file and the audio data of the audio file into a file.
Optionally, how to insert the audio data of the audio file into the file header of the picture file may refer to the encoding methods shown in fig. 1 to fig. 3, which is not described herein again.
Fig. 5 is a schematic view of an implementation flow of a decoding method provided in an embodiment of the present invention, where the decoding method in the embodiment is applicable to an electronic device, and as shown in fig. 5, the decoding method mainly includes the following steps:
step 501: and detecting the format type of the file to be opened.
Here, the file to be opened refers to a picture file, such as a sound photograph, in which image information and audio information are recorded.
Here, the format type refers to a picture coding format used when the file to be opened is synthesized, that is, the picture coding format described in step 501.
Step 502: and searching whether a first identifier exists in the file header of the file to be opened according to the format type.
Here, the first identifier may be an audio identifier or a start identifier.
Step 503: when the first identifier exists, first audio data is acquired based on the first identifier.
It should be noted that, when the first identifier does not exist in the file header, it is indicated that the file to be opened does not include audio information, so that the file to be opened may be opened in the existing manner of opening a file in a common picture format, and details are not described here.
Preferably, the obtaining of the first audio data based on the first identifier may include:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
Of course, the end identifier may also be searched together when the start identifier is searched in step 502.
Preferably, when acquiring the first audio data, the method may further include:
and determining an audio coding format according to the first audio data, and playing the decoded audio data according to the audio coding format.
Step 504: and synchronously decoding the first audio data and the acquired first image data.
Here, the first image data may be acquired upon detecting a format type of the file to be opened; the first image data may also be acquired after the first audio data is acquired based on the first identifier. Of course, there are other ways when the first image data is acquired, which are not listed here.
Preferably, the synchronously decoding the first audio data and the acquired first image data may include:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
Here, the synchronization control technique may be a thread lock technique, an atomic operation technique, or the like.
Preferably, the controlling, by the main thread, the playing of the decoded audio data and the decoded image data may include:
and playing the decoded audio data and image data through a user interface.
In this embodiment, the electronic device may be a mobile phone, a computer, or other device with decoding and playing functions.
Still, the user selects the encoding format to be a JPEG still image. When a user clicks a pre-checked JPEG picture file in a gallery application, an electronic device (or a decoding device) firstly searches whether a previously defined audio identifier 0x9286 exists in the file, if so, acquires related first audio data, and puts the first audio data into an independent sub thread for decoding; and the other sub-thread decodes the acquired first image data through a synchronization technology, and the decoding results of the two sub-threads are returned to the main thread to control the synchronous presentation of pictures and audio on the UI through the main thread.
In the embodiment of the invention, the format type of a file to be opened is detected; searching whether a first identifier exists in a file header of the file to be opened according to the format type; when a first identifier exists, acquiring first audio data based on the first identifier; synchronously decoding the first audio data and the acquired first image data; therefore, the first identifier exists in the file header, the reading of the audio data cannot be influenced, the photos and the audio can be played simultaneously, and the user experience effect is better.
Fig. 6 is a schematic processing flow diagram of a decoding process of a voiced picture according to an embodiment of the present invention, and as shown in fig. 6, the flow includes the following steps:
step 601: detecting the format type of the picture file, and then executing step 602;
specifically, before the electronic device (or decoding apparatus) having the decoding apparatus detects the format type of the picture file, the user may issue an indication to pre-view the picture file by clicking the picture file in the gallery application of the electronic device.
Step 602: searching a file header, and searching whether a first identifier exists in the file header;
here, the first identifier may be an audio identifier or a start identifier.
Specifically, a header of the picture file is retrieved.
Step 603: acquiring first audio data, starting a first sub-thread to decode the first audio data, and sending a decoding result to a main thread;
step 604: adopting a synchronous control technology to control the second sub-thread to decode the first image data, and sending a decoding result to the main thread;
step 605: and the main thread controls the playing of the decoded audio data and the decoded image data.
Specifically, the decoded audio data and image data may be played through a UI interface.
The execution main bodies of the above steps 601 to 605 may be decoding apparatuses, or may be electronic devices having decoding apparatuses.
Fig. 7 is a schematic diagram of a composition structure of an encoding apparatus according to an embodiment of the present invention, and as shown in fig. 7, the encoding apparatus includes a first obtaining unit 71 and a synthesizing unit 72; wherein,
the first obtaining unit 71 is configured to obtain a picture coding format and an audio coding format selected by a user;
the synthesizing unit 72 is configured to insert the first audio data into a file header of a picture file according to a preset policy, and synthesize the first image data and the first audio data into one file.
Preferably, the preset policy may include:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
Preferably, the synthesis unit 72 is specifically configured to:
when the audio identifier is judged to exist, the audio identifier corresponding to the picture coding format is placed in a file header of the picture file, and first audio data are inserted behind the audio identifier;
and after the first audio data is inserted, putting first image data into the audio data.
Preferably, the synthesis unit 72 is further specifically configured to:
when the audio identifier is judged not to exist, a starting identifier is placed in a reserved field of a file header of the picture file, first audio data is inserted after the starting identifier, and a finishing identifier is placed after the first audio data is inserted;
first image data is placed.
In the foregoing scheme, optionally, the encoding apparatus further includes:
a second obtaining unit 73, configured to obtain the picture coding format and the audio coding format selected by the user.
In the foregoing scheme, optionally, the first obtaining unit 71 is further specifically configured to:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
Those skilled in the art will understand that the functions implemented by the processing units in the encoding apparatus shown in fig. 7 can be understood by referring to the related description of the encoding method. Those skilled in the art will understand that each processing unit in the encoding apparatus shown in fig. 7 can be realized by a program running on a processor, and can also be realized by a specific logic circuit.
The first obtaining Unit 71, the synthesizing Unit 72, and the second obtaining Unit 73 in the encoding apparatus described in the above embodiments may be implemented in practical applications by a Central Processing Unit (CPU), a Digital Signal Processor (DSP), or a Programmable Gate Array (FPGA) in the encoding apparatus or an electronic device in which the encoding apparatus is located.
Fig. 8 is a schematic diagram of a composition structure of a decoding apparatus according to an embodiment of the present invention, and as shown in fig. 8, the decoding apparatus includes a detecting unit 81, a searching unit 82, a third obtaining unit 83, and a decoding unit 84; wherein,
the detecting unit 81 is configured to detect a format type of a file to be opened;
the searching unit 82 is configured to search whether a first identifier exists in a file header of the file to be opened according to the format type;
the third obtaining unit 83, configured to, when there is a first identifier, obtain first audio data based on the first identifier;
the decoding unit 84 is configured to synchronously decode the first audio data and the acquired first image data.
Preferably, the third obtaining unit 83 is specifically configured to:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
Preferably, the decoding unit 84 is specifically configured to:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
Preferably, the decoding unit is further specifically configured to:
and playing the decoded audio data and image data through a user interface.
Those skilled in the art will understand that the functions implemented by the processing units in the decoding apparatus shown in fig. 8 can be understood by referring to the related description of the decoding method. Those skilled in the art will understand that each processing unit in the decoding apparatus shown in fig. 8 can be implemented by a program running on a processor, and can also be implemented by a specific logic circuit.
In practical applications, the detecting unit 81, the searching unit 82, the third obtaining unit 83, and the decoding unit 84 in the decoding apparatus according to the above embodiments may be implemented by a CPU, a DSP, or an FPGA in the decoding apparatus or an electronic device in which the decoding apparatus is located.
The invention also describes an electronic device comprising an encoding apparatus as described above, and/or a decoding apparatus as described above.
Specifically, the schematic structural diagram of the encoding apparatus may be as shown in fig. 7, and the schematic structural diagram of the decoding apparatus may be as shown in fig. 8, which are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (14)
1. A method of encoding, the method comprising:
acquiring first image data and first audio data;
inserting the first audio data into a file header of a picture file according to a preset strategy, and synthesizing the first image data and the first audio data into a file,
wherein the preset strategy comprises:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
2. The encoding method according to claim 1, wherein before the obtaining the first image data and the first audio data, further comprising:
and acquiring the picture coding format and the audio coding format selected by the user.
3. The encoding method according to claim 2, wherein the acquiring the first image data and the first audio data includes:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
4. A method of decoding, the method comprising:
detecting the format type of a file to be opened;
searching whether a first identifier exists in a file header of the file to be opened according to the format type;
when a first identifier exists, acquiring first audio data based on the first identifier;
synchronously decoding the first audio data and the acquired first image data;
wherein the obtaining first audio data based on the first identifier comprises:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
5. The decoding method according to claim 4, wherein said synchronously decoding the first audio data and the acquired first image data comprises:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
6. The decoding method according to claim 5, wherein the controlling, by the main thread, the playing of the decoded audio data and the decoded image data comprises:
and playing the decoded audio data and image data through a user interface.
7. An encoding apparatus characterized by comprising a first acquisition unit and a synthesis unit; wherein,
the first acquisition unit is used for acquiring first image data and first audio data;
the synthesis unit is used for inserting the first audio data into a file header of a picture file according to a preset strategy and synthesizing the first image data and the first audio data into one file;
wherein the preset strategy comprises:
judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
8. The encoding device of claim 7, further comprising:
and the second acquisition unit is used for acquiring the picture coding format and the audio coding format selected by the user.
9. The encoding apparatus of claim 8, the first obtaining unit further configured to:
coding the acquired picture data according to the picture coding format selected by the user to generate first image data;
and coding the acquired audio data according to the audio coding format selected by the user to generate first audio data.
10. The decoding device is characterized by comprising a detection unit, a search unit, a third acquisition unit and a decoding unit; wherein,
the detection unit is used for detecting the format type of the file to be opened;
the searching unit is used for searching whether a first identifier exists in the file header of the file to be opened according to the format type;
the third acquisition unit is used for acquiring first audio data based on the first identifier when the first identifier exists;
the decoding unit is used for synchronously decoding the first audio data and the acquired first image data;
wherein the third obtaining unit is further configured to:
when the first identifier is an audio identifier, acquiring first audio data positioned behind the audio identifier in a file header of the file to be opened;
when the first identifier is a start identifier, an end identifier is looked up, and first audio data between the start identifier and the end identifier is acquired.
11. The decoding apparatus according to claim 10, wherein the decoding unit is further configured to:
adopting a synchronous control technology to control a first sub-thread to decode first audio data and a second sub-thread to decode first image data; the first sub-thread and the second sub-thread are independent sub-threads;
and returning the decoding result of the first audio data and the decoding result of the first image data to the main thread so that the main thread controls the playing of the decoded audio data and the decoded image data.
12. The decoding apparatus according to claim 10, wherein the decoding unit is further configured to:
and playing the decoded audio data and image data through a user interface.
13. An electronic device, characterized in that it comprises at least an encoding device according to any one of claims 7 to 9 and/or a decoding device according to any one of claims 10 to 12.
14. A method for generating a voiced picture, the method comprising:
acquiring at least one picture file and an audio file;
inserting the audio data of the audio file into a file header of the picture file, and synthesizing the image data of the picture file and the audio data of the audio file into a file;
inserting the audio data of the audio file into the file header of the picture file specifically comprises: judging whether the pre-adopted picture coding format has an audio identifier in the image file format standard;
when there is an audio identifier, the audio identifier,
placing an audio identifier corresponding to the picture coding format in a file header of a picture file, and inserting first audio data after the audio identifier; after the first audio data are inserted, first image data are placed;
when there is no audio identifier, the audio identifier,
a start identifier is placed in a reserved field of a file header of a picture file, first audio data is inserted after the start identifier, and an end identifier is placed after the first audio data is inserted;
first image data is placed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510283432.2A CN104916298B (en) | 2015-05-28 | 2015-05-28 | Decoding method, coding and decoding device, electronic equipment and talking picture generation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510283432.2A CN104916298B (en) | 2015-05-28 | 2015-05-28 | Decoding method, coding and decoding device, electronic equipment and talking picture generation method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104916298A CN104916298A (en) | 2015-09-16 |
CN104916298B true CN104916298B (en) | 2018-05-11 |
Family
ID=54085322
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510283432.2A Active CN104916298B (en) | 2015-05-28 | 2015-05-28 | Decoding method, coding and decoding device, electronic equipment and talking picture generation method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104916298B (en) |
Families Citing this family (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105472289B (en) * | 2015-11-11 | 2019-02-22 | 努比亚技术有限公司 | Edit the device and method of sound photo |
CN105407282A (en) * | 2015-11-16 | 2016-03-16 | 中科创达软件股份有限公司 | Photographing method and replay method |
CN105677717B (en) * | 2015-12-29 | 2019-04-19 | 努比亚技术有限公司 | A kind of display methods and terminal |
CN106777204B (en) * | 2016-12-23 | 2020-08-07 | 北京安云世纪科技有限公司 | Image data processing method, device and mobile terminal |
CN106791442B (en) * | 2017-01-20 | 2019-11-15 | 维沃移动通信有限公司 | A kind of image pickup method and mobile terminal |
CN112151048B (en) * | 2019-06-11 | 2024-04-02 | 李庆成 | Method for generating and processing audio-visual data |
CN111354384A (en) * | 2020-02-27 | 2020-06-30 | 北京奇艺世纪科技有限公司 | GIF picture generation method, playing method and device and electronic equipment |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1199892A4 (en) * | 2000-03-14 | 2006-08-09 | Matsushita Electric Ind Co Ltd | DEVICE AND METHOD FOR REPRODUCING IMAGES AND VOICE |
CN101986302B (en) * | 2010-10-28 | 2012-10-17 | 华为终端有限公司 | Media file association method and device |
CN102609968B (en) * | 2012-03-05 | 2015-06-24 | 深圳市优利麦克科技开发有限公司 | Method and system for realizing audio picture |
CN104580888B (en) * | 2014-12-17 | 2018-09-04 | 广东欧珀移动通信有限公司 | A kind of image processing method and terminal |
-
2015
- 2015-05-28 CN CN201510283432.2A patent/CN104916298B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN104916298A (en) | 2015-09-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104916298B (en) | Decoding method, coding and decoding device, electronic equipment and talking picture generation method | |
JP6367334B2 (en) | Video processing method, apparatus, and playback apparatus | |
KR100856407B1 (en) | Apparatus and method for data recording and reproducing metadata | |
JP4988011B2 (en) | Electronic apparatus and image processing method | |
WO2018149175A1 (en) | Video-recording method and apparatus, and electronic device | |
CN104580888B (en) | A kind of image processing method and terminal | |
TWI287399B (en) | Information processing apparatus and method and recording medium storing program therefor | |
CN101662595B (en) | Electronic apparatus, method of changing a moving image data section | |
JP4379491B2 (en) | Face data recording device, playback device, imaging device, image playback system, face data recording method and program | |
JP2010034763A (en) | Recording device and method, reproducing device and method, and program | |
WO2015074203A1 (en) | Picture displaying method, apparatus and terminal device | |
KR20140089771A (en) | Apparatus and method for photographing image having audio data | |
WO2009002382A1 (en) | Method and system for facilitating creation of content | |
JP4478566B2 (en) | Method and apparatus for linking multimedia data | |
JP4892074B2 (en) | Electronic device, image output method and program | |
JP2009225415A (en) | Mobile multimedia broadcasting device with position instructing function and multimedia file broadcasting method | |
JP4940333B2 (en) | Electronic apparatus and moving image reproduction method | |
JP5225330B2 (en) | Electronic apparatus and image processing method | |
WO2015085862A1 (en) | Method and apparatus for playing 3d film sources in smart tv | |
JP2012138804A (en) | Image processor, image processing method, and program | |
WO2016184193A1 (en) | Method and apparatus for generating media files | |
JP2005327257A (en) | File management method and apparatus for controlling asset in multimedia appliance and information recording medium therefor | |
Suzuki et al. | AnnoTone: Record-time audio watermarking for context-aware video editing | |
JP2003309815A (en) | Information recording medium and production method therefor | |
JP4692336B2 (en) | Image display system, image display apparatus, and image display method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |